Skip to content

Commit f46e251

Browse files
committed
pythongh-92886: make test_multiprocessing pass with -O (assertions off)
1 parent be4099e commit f46e251

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Lib/test/_test_multiprocessing.py

+19-13
Original file line numberDiff line numberDiff line change
@@ -5698,15 +5698,18 @@ def test_joinable_queue(self):
56985698

56995699
@classmethod
57005700
def _test_list(cls, obj):
5701-
assert obj[0] == 5
5702-
assert obj.count(5) == 1
5703-
assert obj.index(5) == 0
5701+
def check(a, b):
5702+
if a != b:
5703+
raise AssertionError(f"{a} != {b}")
5704+
check(obj[0], 5)
5705+
check(obj.count(5), 1)
5706+
check(obj.index(5), 0)
57045707
obj.sort()
57055708
obj.reverse()
57065709
for x in obj:
57075710
pass
5708-
assert len(obj) == 1
5709-
assert obj.pop(0) == 5
5711+
check(len(obj), 1)
5712+
check(obj.pop(0), 5)
57105713

57115714
def test_list(self):
57125715
o = self.manager.list()
@@ -5717,14 +5720,17 @@ def test_list(self):
57175720

57185721
@classmethod
57195722
def _test_dict(cls, obj):
5720-
assert len(obj) == 1
5721-
assert obj['foo'] == 5
5722-
assert obj.get('foo') == 5
5723-
assert list(obj.items()) == [('foo', 5)]
5724-
assert list(obj.keys()) == ['foo']
5725-
assert list(obj.values()) == [5]
5726-
assert obj.copy() == {'foo': 5}
5727-
assert obj.popitem() == ('foo', 5)
5723+
def check(a, b):
5724+
if a != b:
5725+
raise AssertionError(f"{a} != {b}")
5726+
check(len(obj), 1)
5727+
check(obj['foo'], 5)
5728+
check(obj.get('foo'), 5)
5729+
check(list(obj.items()), [('foo', 5)])
5730+
check(list(obj.keys()), ['foo'])
5731+
check(list(obj.values()), [5])
5732+
check(obj.copy(), {'foo': 5})
5733+
check(obj.popitem(), ('foo', 5))
57285734

57295735
def test_dict(self):
57305736
o = self.manager.dict()

0 commit comments

Comments
 (0)