]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39932: Fix multiprocessing test_heap() (GH-19690)
authorVictor Stinner <vstinner@python.org>
Thu, 23 Apr 2020 22:20:00 +0000 (00:20 +0200)
committerGitHub <noreply@github.com>
Thu, 23 Apr 2020 22:20:00 +0000 (00:20 +0200)
bpo-32759, bpo-39932: Fix multiprocessing test_heap():
a new Heap object is now created for each test run.

Partial backport of commit e4679cd644aa19f9d9df9beb1326625cf2b02c15
by Antoine Pitrou.

Lib/test/_test_multiprocessing.py
Misc/NEWS.d/next/Tests/2020-04-23-23-46-08.bpo-39932.6G8rRN.rst [new file with mode: 0644]

index 30ea23da694991efd52d206262a287f05eb3ca8e..a889ad3ae39181c65f68bc52535703f29a4e9b67 100644 (file)
@@ -3424,6 +3424,16 @@ class _TestHeap(BaseTestCase):
 
     ALLOWED_TYPES = ('processes',)
 
+    def setUp(self):
+        super().setUp()
+        # Make pristine heap for these tests
+        self.old_heap = multiprocessing.heap.BufferWrapper._heap
+        multiprocessing.heap.BufferWrapper._heap = multiprocessing.heap.Heap()
+
+    def tearDown(self):
+        multiprocessing.heap.BufferWrapper._heap = self.old_heap
+        super().tearDown()
+
     def test_heap(self):
         iterations = 5000
         maxblocks = 50
diff --git a/Misc/NEWS.d/next/Tests/2020-04-23-23-46-08.bpo-39932.6G8rRN.rst b/Misc/NEWS.d/next/Tests/2020-04-23-23-46-08.bpo-39932.6G8rRN.rst
new file mode 100644 (file)
index 0000000..c50be57
--- /dev/null
@@ -0,0 +1,2 @@
+Fix multiprocessing test_heap(): a new Heap object is now created for each test
+run.