Skip to content

Commit 92da1cf

Browse files
committed
test: manually update big-endian tests
1 parent 560ebcb commit 92da1cf

2 files changed

Lines changed: 152 additions & 264 deletions

File tree

test/test_events_be.py

Lines changed: 27 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,17 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python2
22

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__, '../..')))
55

66
import unittest
77
from Xlib.protocol import request, rq, event
8-
import Xlib.protocol.event
8+
from . import BigEndianTest as EndianTest
9+
from . import DummyDisplay
910

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
6311
dummy_display = DummyDisplay()
6412

6513

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):
7415
def setUp(self):
7516
self.evt_args_0 = {
7617
'type': 154,
@@ -101,7 +42,7 @@ def testUnpack0(self):
10142
raise AssertionError(args)
10243

10344

104-
class TestExpose(unittest.TestCase):
45+
class TestExpose(EndianTest):
10546
def setUp(self):
10647
self.evt_args_0 = {
10748
'height': 22214,
@@ -138,7 +79,7 @@ def testUnpack0(self):
13879
raise AssertionError(args)
13980

14081

141-
class TestGraphicsExpose(unittest.TestCase):
82+
class TestGraphicsExpose(EndianTest):
14283
def setUp(self):
14384
self.evt_args_0 = {
14485
'height': 352,
@@ -177,7 +118,7 @@ def testUnpack0(self):
177118
raise AssertionError(args)
178119

179120

180-
class TestNoExpose(unittest.TestCase):
121+
class TestNoExpose(EndianTest):
181122
def setUp(self):
182123
self.evt_args_0 = {
183124
'sequence_number': 46171,
@@ -211,7 +152,7 @@ def testUnpack0(self):
211152
raise AssertionError(args)
212153

213154

214-
class TestVisibilityNotify(unittest.TestCase):
155+
class TestVisibilityNotify(EndianTest):
215156
def setUp(self):
216157
self.evt_args_0 = {
217158
'state': 238,
@@ -244,7 +185,7 @@ def testUnpack0(self):
244185
raise AssertionError(args)
245186

246187

247-
class TestCreateNotify(unittest.TestCase):
188+
class TestCreateNotify(EndianTest):
248189
def setUp(self):
249190
self.evt_args_0 = {
250191
'height': 15506,
@@ -283,7 +224,7 @@ def testUnpack0(self):
283224
raise AssertionError(args)
284225

285226

286-
class TestDestroyNotify(unittest.TestCase):
227+
class TestDestroyNotify(EndianTest):
287228
def setUp(self):
288229
self.evt_args_0 = {
289230
'sequence_number': 49137,
@@ -316,7 +257,7 @@ def testUnpack0(self):
316257
raise AssertionError(args)
317258

318259

319-
class TestUnmapNotify(unittest.TestCase):
260+
class TestUnmapNotify(EndianTest):
320261
def setUp(self):
321262
self.evt_args_0 = {
322263
'from_configure': 0,
@@ -350,7 +291,7 @@ def testUnpack0(self):
350291
raise AssertionError(args)
351292

352293

353-
class TestMapNotify(unittest.TestCase):
294+
class TestMapNotify(EndianTest):
354295
def setUp(self):
355296
self.evt_args_0 = {
356297
'sequence_number': 65096,
@@ -384,7 +325,7 @@ def testUnpack0(self):
384325
raise AssertionError(args)
385326

386327

387-
class TestMapRequest(unittest.TestCase):
328+
class TestMapRequest(EndianTest):
388329
def setUp(self):
389330
self.evt_args_0 = {
390331
'parent': 1664235152,
@@ -417,7 +358,7 @@ def testUnpack0(self):
417358
raise AssertionError(args)
418359

419360

420-
class TestReparentNotify(unittest.TestCase):
361+
class TestReparentNotify(EndianTest):
421362
def setUp(self):
422363
self.evt_args_0 = {
423364
'sequence_number': 9256,
@@ -454,7 +395,7 @@ def testUnpack0(self):
454395
raise AssertionError(args)
455396

456397

457-
class TestConfigureNotify(unittest.TestCase):
398+
class TestConfigureNotify(EndianTest):
458399
def setUp(self):
459400
self.evt_args_0 = {
460401
'height': 16243,
@@ -494,7 +435,7 @@ def testUnpack0(self):
494435
raise AssertionError(args)
495436

496437

497-
class TestConfigureRequest(unittest.TestCase):
438+
class TestConfigureRequest(EndianTest):
498439
def setUp(self):
499440
self.evt_args_0 = {
500441
'sequence_number': 31377,
@@ -535,7 +476,7 @@ def testUnpack0(self):
535476
raise AssertionError(args)
536477

537478

538-
class TestGravityNotify(unittest.TestCase):
479+
class TestGravityNotify(EndianTest):
539480
def setUp(self):
540481
self.evt_args_0 = {
541482
'sequence_number': 43376,
@@ -570,7 +511,7 @@ def testUnpack0(self):
570511
raise AssertionError(args)
571512

572513

573-
class TestResizeRequest(unittest.TestCase):
514+
class TestResizeRequest(EndianTest):
574515
def setUp(self):
575516
self.evt_args_0 = {
576517
'height': 59752,
@@ -604,7 +545,7 @@ def testUnpack0(self):
604545
raise AssertionError(args)
605546

606547

607-
class TestPropertyNotify(unittest.TestCase):
548+
class TestPropertyNotify(EndianTest):
608549
def setUp(self):
609550
self.evt_args_0 = {
610551
'atom': 762586168,
@@ -639,7 +580,7 @@ def testUnpack0(self):
639580
raise AssertionError(args)
640581

641582

642-
class TestSelectionClear(unittest.TestCase):
583+
class TestSelectionClear(EndianTest):
643584
def setUp(self):
644585
self.evt_args_0 = {
645586
'time': 578079299,
@@ -673,7 +614,7 @@ def testUnpack0(self):
673614
raise AssertionError(args)
674615

675616

676-
class TestSelectionRequest(unittest.TestCase):
617+
class TestSelectionRequest(EndianTest):
677618
def setUp(self):
678619
self.evt_args_0 = {
679620
'sequence_number': 13254,
@@ -710,7 +651,7 @@ def testUnpack0(self):
710651
raise AssertionError(args)
711652

712653

713-
class TestSelectionNotify(unittest.TestCase):
654+
class TestSelectionNotify(EndianTest):
714655
def setUp(self):
715656
self.evt_args_0 = {
716657
'sequence_number': 39736,
@@ -746,7 +687,7 @@ def testUnpack0(self):
746687
raise AssertionError(args)
747688

748689

749-
class TestColormapNotify(unittest.TestCase):
690+
class TestColormapNotify(EndianTest):
750691
def setUp(self):
751692
self.evt_args_0 = {
752693
'state': 209,
@@ -781,7 +722,7 @@ def testUnpack0(self):
781722
raise AssertionError(args)
782723

783724

784-
class TestClientMessage(unittest.TestCase):
725+
class TestClientMessage(EndianTest):
785726
def setUp(self):
786727
self.evt_args_0 = {
787728
'sequence_number': 48712,
@@ -875,7 +816,7 @@ def testUnpack2(self):
875816
raise AssertionError(args)
876817

877818

878-
class TestMappingNotify(unittest.TestCase):
819+
class TestMappingNotify(EndianTest):
879820
def setUp(self):
880821
self.evt_args_0 = {
881822
'sequence_number': 53541,

0 commit comments

Comments
 (0)