From f46e25121dd0111e4ced19f30deffa7aedf7f7bd Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Fri, 7 Oct 2022 22:39:21 +0100 Subject: [PATCH] gh-92886: make test_multiprocessing pass with -O (assertions off) --- Lib/test/_test_multiprocessing.py | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index f74d8d7fbd726c..a9d516cd62bea2 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -5698,15 +5698,18 @@ def test_joinable_queue(self): @classmethod def _test_list(cls, obj): - assert obj[0] == 5 - assert obj.count(5) == 1 - assert obj.index(5) == 0 + def check(a, b): + if a != b: + raise AssertionError(f"{a} != {b}") + check(obj[0], 5) + check(obj.count(5), 1) + check(obj.index(5), 0) obj.sort() obj.reverse() for x in obj: pass - assert len(obj) == 1 - assert obj.pop(0) == 5 + check(len(obj), 1) + check(obj.pop(0), 5) def test_list(self): o = self.manager.list() @@ -5717,14 +5720,17 @@ def test_list(self): @classmethod def _test_dict(cls, obj): - assert len(obj) == 1 - assert obj['foo'] == 5 - assert obj.get('foo') == 5 - assert list(obj.items()) == [('foo', 5)] - assert list(obj.keys()) == ['foo'] - assert list(obj.values()) == [5] - assert obj.copy() == {'foo': 5} - assert obj.popitem() == ('foo', 5) + def check(a, b): + if a != b: + raise AssertionError(f"{a} != {b}") + check(len(obj), 1) + check(obj['foo'], 5) + check(obj.get('foo'), 5) + check(list(obj.items()), [('foo', 5)]) + check(list(obj.keys()), ['foo']) + check(list(obj.values()), [5]) + check(obj.copy(), {'foo': 5}) + check(obj.popitem(), ('foo', 5)) def test_dict(self): o = self.manager.dict()