8000 gh-92886: Fix tests that fail when running with optimizations (`-O`) … · python/cpython@a3be874 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3be874

Browse files
authored
gh-92886: Fix tests that fail when running with optimizations (-O) in _test_multiprocessing.py (GH-93233)
1 parent 602ea40 commit a3be874

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,45 +5698,48 @@ 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+
case = unittest.TestCase()
5702+
case.assertEqual(obj[0], 5)
5703+
case.assertEqual(obj.count(5), 1)
5704+
case.assertEqual(obj.index(5), 0)
57045705
obj.sort()
57055706
obj.reverse()
57065707
for x in obj:
57075708
pass
5708-
assert len(obj) == 1
5709-
assert obj.pop(0) == 5
5709+
case.assertEqual(len(obj), 1)
5710+
case.assertEqual(obj.pop(0), 5)
57105711

57115712
def test_list(self):
57125713
o = self.manager.list()
57135714
o.append(5)
57145715
self.run_worker(self._test_list, o)
5715-
assert not o
5716+
self.assertIsNotNone(o)
57165717
self.assertEqual(len(o), 0)
57175718

57185719
@classmethod
57195720
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)
5721+
case = unittest.TestCase()
5722+
case.assertEqual(len(obj), 1)
5723+
case.assertEqual(obj['foo'], 5)
5724+
case.assertEqual(obj.get('foo'), 5)
5725+
case.assertListEqual(list(obj.items()), [('foo', 5)])
5726+
case.assertListEqual(list(obj.keys()), ['foo'])
5727+
case.assertListEqual(list(obj.values()), [5])
5728+
case.assertDictEqual(obj.copy(), {'foo': 5})
5729+
case.assertTupleEqual(obj.popitem(), ('foo', 5))
57285730

57295731
def test_dict(self):
57305732
o = self.manager.dict()
57315733
o['foo'] = 5
57325734
self.run_worker(self._test_dict, o)
5733-
assert not o
5735+
self.assertIsNotNone(o)
57345736
self.assertEqual(len(o), 0)
57355737

57365738
@classmethod
57375739
def _test_value(cls, obj):
5738-
assert obj.value == 1
5739-
assert obj.get() == 1
5740+
case = unittest.TestCase()
5741+
case.assertEqual(obj.value, 1)
5742+
case.assertEqual(obj.get(), 1)
57405743
obj.set(2)
57415744

57425745
def test_value(self):
@@ -5747,19 +5750,21 @@ def test_value(self):
57475750

57485751
@classmethod
57495752
def _test_array(cls, obj):
5750-
assert obj[0] == 0
5751-
assert obj[1] == 1
5752-
assert len(obj) == 2
5753-
assert list(obj) == [0, 1]
5753+
case = unittest.TestCase()
5754+
case.assertEqual(obj[0], 0)
5755+
case.assertEqual(obj[1], 1)
5756+
case.assertEqual(len(obj), 2)
5757+
case.assertListEqual(list(obj), [0, 1])
57545758

57555759
def test_array(self):
57565760
o = self.manager.Array('i', [0, 1])
57575761
self.run_worker(self._test_array, o)
57585762

57595763
@classmethod
57605764
def _test_namespace(cls, obj):
5761-
assert obj.x == 0
5762-
assert obj.y == 1
5765+
case = unittest.TestCase()
5766+
case.assertEqual(obj.x, 0)
5767+
case.assertEqual(obj.y, 1)
57635768

57645769
def test_namespace(self):
57655770
o = self.manager.Namespace()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixing tests that fail when running with optimizations (``-O``) in ``_test_multiprocessing.py``

0 commit comments

Comments
 (0)
0