#!/usr/bin/env python

import sys
import os
import unittest

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

import Xlib.display
import Xlib.protocol.display


class TestXlibDisplay(unittest.TestCase):
    def setUp(self):
        self.display = Xlib.display.Display(":99.0")

    def test_display_instance(self):
        print "1"
        self.assertIsInstance(self.display, Xlib.display.Display)

    def test_default_DisplayName(self):
        print "2"
        self.assertEqual(self.display.get_display_name(), ":99.0")

    def test_default_screenNumber(self):
        self.assertEqual(self.display.get_default_screen(), 0)

    def test_returns_no_events(self):
        self.assertEqual(self.display.pending_events(), 0)

    def test_pointer_mapping_is_list(self):
        self.assertIsInstance(self.display.get_pointer_mapping(), list)

    def test_set_get_pointer_mapping(self):
        length = len(self.display.get_pointer_mapping())
        self.display.set_pointer_mapping([0] * length)
        self.assertEqual(self.display.get_pointer_mapping(), [0] * length)


if __name__ == '__main__':
    unittest.main()

@@ -52,16 +52,34 @@
 unittest
+%0Aimport subprocess
 %0A%0Asys.pa
@@ -242,32 +242,360 @@
 ef setUp(self):%0A
+        # Create authority file.%0A%0A        self.authfile = os.path.join(os.getenv(%22HOME%22), %22.Xauthority%22)%0A        self.cookie = %22926e3f51b3540ca0d54bf2725c1af2b6%22 #subprocess.check_output(%5B%22%60ps -ef %7C md5sum %7C cut -f 1 -d %22 %22%60%22%5D)%0A        os.system(%22xauth -f %7B%7D add :99.0 MIT-MAGIC-COOKIE-1 %7B%7D%22.format(self.authfile, self.cookie))%0A
         self.dis
@@ -779,16 +779,17 @@
 ult_
-D
+d
 isplay
-N
+_n
 ame(
@@ -912,9 +912,10 @@
 reen
-N
+_n
 umbe
@@ -1358,16 +1358,16 @@
 length)%0A
-
         
@@ -1434,16 +1434,74 @@
 ength)%0A%0A
+    def tearDown(self):%0A        os.remove(self.authfile)%0A%0A
 %0Aif __na

fix auth