|
1 | | -#!/usr/bin/env python |
| 1 | +#!/usr/bin/env python2 |
2 | 2 |
|
3 | | -import sys, os |
4 | | -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 3 | +import sys, os, difflib |
| 4 | +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) |
5 | 5 |
|
6 | 6 | import unittest |
7 | 7 | from Xlib.protocol import request, rq, event |
8 | | -import Xlib.protocol.event |
| 8 | +from . import BigEndianTest as EndianTest |
| 9 | +from . import DummyDisplay |
9 | 10 |
|
10 | | -import struct |
11 | | -import array |
12 | | - |
13 | | -class CmpArray(object): |
14 | | - def __init__(self, *args, **kws): |
15 | | - self.array = array.array(*args, **kws) |
16 | | - |
17 | | - def __len__(self): |
18 | | - return len(self.array) |
19 | | - |
20 | | - def __getitem__(self, key): |
21 | | - if isinstance(key, slice): |
22 | | - x = key.start |
23 | | - y = key.stop |
24 | | - return list(self.array[x:y]) |
25 | | - else: |
26 | | - return self.array[key] |
27 | | - |
28 | | - def __getattr__(self, attr): |
29 | | - return getattr(self.array, attr) |
30 | | - |
31 | | - def __lt__(self, other): |
32 | | - return self.array.tolist() < other |
33 | | - |
34 | | - def __gt__(self, other): |
35 | | - return self.array.tolist() > other |
36 | | - |
37 | | - def __eq__(self, other): |
38 | | - return self.array.tolist() == other |
39 | | - |
40 | | -rq.array = CmpArray |
41 | | - |
42 | | -def tohex(bin): |
43 | | - bin = ''.join(map(lambda c: '\\x%02x' % ord(c), bin)) |
44 | | - |
45 | | - bins = [] |
46 | | - for i in range(0, len(bin), 16): |
47 | | - bins.append(bin[i:i+16]) |
48 | | - |
49 | | - bins2 = [] |
50 | | - for i in range(0, len(bins), 2): |
51 | | - try: |
52 | | - bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) |
53 | | - except IndexError: |
54 | | - bins2.append("'%s'" % bins[i]) |
55 | | - |
56 | | - return ' \\\n '.join(bins2) |
57 | | - |
58 | | -class DummyDisplay: |
59 | | - def get_resource_class(self, x): |
60 | | - return None |
61 | | - |
62 | | - event_classes = Xlib.protocol.event.event_class |
63 | 11 | dummy_display = DummyDisplay() |
64 | 12 |
|
65 | 13 |
|
66 | | -def check_endian(): |
67 | | - if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: |
68 | | - sys.stderr.write('Big-endian tests, skipping on this system.\n') |
69 | | - sys.exit(0) |
70 | | - |
71 | | - |
72 | | - |
73 | | -class TestKeymapNotify(unittest.TestCase): |
| 14 | +class TestKeymapNotify(EndianTest): |
74 | 15 | def setUp(self): |
75 | 16 | self.evt_args_0 = { |
76 | 17 | 'type': 154, |
@@ -101,7 +42,7 @@ def testUnpack0(self): |
101 | 42 | raise AssertionError(args) |
102 | 43 |
|
103 | 44 |
|
104 | | -class TestExpose(unittest.TestCase): |
| 45 | +class TestExpose(EndianTest): |
105 | 46 | def setUp(self): |
106 | 47 | self.evt_args_0 = { |
107 | 48 | 'height': 22214, |
@@ -138,7 +79,7 @@ def testUnpack0(self): |
138 | 79 | raise AssertionError(args) |
139 | 80 |
|
140 | 81 |
|
141 | | -class TestGraphicsExpose(unittest.TestCase): |
| 82 | +class TestGraphicsExpose(EndianTest): |
142 | 83 | def setUp(self): |
143 | 84 | self.evt_args_0 = { |
144 | 85 | 'height': 352, |
@@ -177,7 +118,7 @@ def testUnpack0(self): |
177 | 118 | raise AssertionError(args) |
178 | 119 |
|
179 | 120 |
|
180 | | -class TestNoExpose(unittest.TestCase): |
| 121 | +class TestNoExpose(EndianTest): |
181 | 122 | def setUp(self): |
182 | 123 | self.evt_args_0 = { |
183 | 124 | 'sequence_number': 46171, |
@@ -211,7 +152,7 @@ def testUnpack0(self): |
211 | 152 | raise AssertionError(args) |
212 | 153 |
|
213 | 154 |
|
214 | | -class TestVisibilityNotify(unittest.TestCase): |
| 155 | +class TestVisibilityNotify(EndianTest): |
215 | 156 | def setUp(self): |
216 | 157 | self.evt_args_0 = { |
217 | 158 | 'state': 238, |
@@ -244,7 +185,7 @@ def testUnpack0(self): |
244 | 185 | raise AssertionError(args) |
245 | 186 |
|
246 | 187 |
|
247 | | -class TestCreateNotify(unittest.TestCase): |
| 188 | +class TestCreateNotify(EndianTest): |
248 | 189 | def setUp(self): |
249 | 190 | self.evt_args_0 = { |
250 | 191 | 'height': 15506, |
@@ -283,7 +224,7 @@ def testUnpack0(self): |
283 | 224 | raise AssertionError(args) |
284 | 225 |
|
285 | 226 |
|
286 | | -class TestDestroyNotify(unittest.TestCase): |
| 227 | +class TestDestroyNotify(EndianTest): |
287 | 228 | def setUp(self): |
288 | 229 | self.evt_args_0 = { |
289 | 230 | 'sequence_number': 49137, |
@@ -316,7 +257,7 @@ def testUnpack0(self): |
316 | 257 | raise AssertionError(args) |
317 | 258 |
|
318 | 259 |
|
319 | | -class TestUnmapNotify(unittest.TestCase): |
| 260 | +class TestUnmapNotify(EndianTest): |
320 | 261 | def setUp(self): |
321 | 262 | self.evt_args_0 = { |
322 | 263 | 'from_configure': 0, |
@@ -350,7 +291,7 @@ def testUnpack0(self): |
350 | 291 | raise AssertionError(args) |
351 | 292 |
|
352 | 293 |
|
353 | | -class TestMapNotify(unittest.TestCase): |
| 294 | +class TestMapNotify(EndianTest): |
354 | 295 | def setUp(self): |
355 | 296 | self.evt_args_0 = { |
356 | 297 | 'sequence_number': 65096, |
@@ -384,7 +325,7 @@ def testUnpack0(self): |
384 | 325 | raise AssertionError(args) |
385 | 326 |
|
386 | 327 |
|
387 | | -class TestMapRequest(unittest.TestCase): |
| 328 | +class TestMapRequest(EndianTest): |
388 | 329 | def setUp(self): |
389 | 330 | self.evt_args_0 = { |
390 | 331 | 'parent': 1664235152, |
@@ -417,7 +358,7 @@ def testUnpack0(self): |
417 | 358 | raise AssertionError(args) |
418 | 359 |
|
419 | 360 |
|
420 | | -class TestReparentNotify(unittest.TestCase): |
| 361 | +class TestReparentNotify(EndianTest): |
421 | 362 | def setUp(self): |
422 | 363 | self.evt_args_0 = { |
423 | 364 | 'sequence_number': 9256, |
@@ -454,7 +395,7 @@ def testUnpack0(self): |
454 | 395 | raise AssertionError(args) |
455 | 396 |
|
456 | 397 |
|
457 | | -class TestConfigureNotify(unittest.TestCase): |
| 398 | +class TestConfigureNotify(EndianTest): |
458 | 399 | def setUp(self): |
459 | 400 | self.evt_args_0 = { |
460 | 401 | 'height': 16243, |
@@ -494,7 +435,7 @@ def testUnpack0(self): |
494 | 435 | raise AssertionError(args) |
495 | 436 |
|
496 | 437 |
|
497 | | -class TestConfigureRequest(unittest.TestCase): |
| 438 | +class TestConfigureRequest(EndianTest): |
498 | 439 | def setUp(self): |
499 | 440 | self.evt_args_0 = { |
500 | 441 | 'sequence_number': 31377, |
@@ -535,7 +476,7 @@ def testUnpack0(self): |
535 | 476 | raise AssertionError(args) |
536 | 477 |
|
537 | 478 |
|
538 | | -class TestGravityNotify(unittest.TestCase): |
| 479 | +class TestGravityNotify(EndianTest): |
539 | 480 | def setUp(self): |
540 | 481 | self.evt_args_0 = { |
541 | 482 | 'sequence_number': 43376, |
@@ -570,7 +511,7 @@ def testUnpack0(self): |
570 | 511 | raise AssertionError(args) |
571 | 512 |
|
572 | 513 |
|
573 | | -class TestResizeRequest(unittest.TestCase): |
| 514 | +class TestResizeRequest(EndianTest): |
574 | 515 | def setUp(self): |
575 | 516 | self.evt_args_0 = { |
576 | 517 | 'height': 59752, |
@@ -604,7 +545,7 @@ def testUnpack0(self): |
604 | 545 | raise AssertionError(args) |
605 | 546 |
|
606 | 547 |
|
607 | | -class TestPropertyNotify(unittest.TestCase): |
| 548 | +class TestPropertyNotify(EndianTest): |
608 | 549 | def setUp(self): |
609 | 550 | self.evt_args_0 = { |
610 | 551 | 'atom': 762586168, |
@@ -639,7 +580,7 @@ def testUnpack0(self): |
639 | 580 | raise AssertionError(args) |
640 | 581 |
|
641 | 582 |
|
642 | | -class TestSelectionClear(unittest.TestCase): |
| 583 | +class TestSelectionClear(EndianTest): |
643 | 584 | def setUp(self): |
644 | 585 | self.evt_args_0 = { |
645 | 586 | 'time': 578079299, |
@@ -673,7 +614,7 @@ def testUnpack0(self): |
673 | 614 | raise AssertionError(args) |
674 | 615 |
|
675 | 616 |
|
676 | | -class TestSelectionRequest(unittest.TestCase): |
| 617 | +class TestSelectionRequest(EndianTest): |
677 | 618 | def setUp(self): |
678 | 619 | self.evt_args_0 = { |
679 | 620 | 'sequence_number': 13254, |
@@ -710,7 +651,7 @@ def testUnpack0(self): |
710 | 651 | raise AssertionError(args) |
711 | 652 |
|
712 | 653 |
|
713 | | -class TestSelectionNotify(unittest.TestCase): |
| 654 | +class TestSelectionNotify(EndianTest): |
714 | 655 | def setUp(self): |
715 | 656 | self.evt_args_0 = { |
716 | 657 | 'sequence_number': 39736, |
@@ -746,7 +687,7 @@ def testUnpack0(self): |
746 | 687 | raise AssertionError(args) |
747 | 688 |
|
748 | 689 |
|
749 | | -class TestColormapNotify(unittest.TestCase): |
| 690 | +class TestColormapNotify(EndianTest): |
750 | 691 | def setUp(self): |
751 | 692 | self.evt_args_0 = { |
752 | 693 | 'state': 209, |
@@ -781,7 +722,7 @@ def testUnpack0(self): |
781 | 722 | raise AssertionError(args) |
782 | 723 |
|
783 | 724 |
|
784 | | -class TestClientMessage(unittest.TestCase): |
| 725 | +class TestClientMessage(EndianTest): |
785 | 726 | def setUp(self): |
786 | 727 | self.evt_args_0 = { |
787 | 728 | 'sequence_number': 48712, |
@@ -875,7 +816,7 @@ def testUnpack2(self): |
875 | 816 | raise AssertionError(args) |
876 | 817 |
|
877 | 818 |
|
878 | | -class TestMappingNotify(unittest.TestCase): |
| 819 | +class TestMappingNotify(EndianTest): |
879 | 820 | def setUp(self): |
880 | 821 | self.evt_args_0 = { |
881 | 822 | 'sequence_number': 53541, |
|
0 commit comments