Skip to content

Commit

Permalink
split tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pan324 committed Dec 1, 2023
1 parent a5848c1 commit 8255e01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4444,8 +4444,7 @@ def test_shared_memory_cleaned_after_process_termination(self):
def test_shared_memory_untracking(self):
# gh-82300: When a separate Python process accesses shared memory
# with track=False, it must not cause the memory to be deleted
# when terminating. When accessing with track=True, it must be
# deleted.
# when terminating.
cmd = '''if 1:
import sys
from multiprocessing.shared_memory import SharedMemory
Expand All @@ -4457,6 +4456,7 @@ def test_shared_memory_untracking(self):
# err existing means that the tracker process has terminated now.
try:
rc, out, err = script_helper.assert_python_ok("-c", cmd, mem.name)
self.assertNotIn(b"resource_tracker", err)
self.assertEqual(rc, 0)
mem2 = shared_memory.SharedMemory(create=False, name=mem.name)
mem2.close()
Expand All @@ -4466,6 +4466,11 @@ def test_shared_memory_untracking(self):
except OSError:
pass
mem.close()
@unittest.skipIf(os.name != "posix", "resource_tracker is posix only")
def test_shared_memory_tracking(self):
# gh-82300: When a separate Python process accesses shared memory
# with track=True, it must cause the memory to be deleted when
# terminating.
cmd = '''if 1:
import sys
from multiprocessing.shared_memory import SharedMemory
Expand All @@ -4475,6 +4480,7 @@ def test_shared_memory_untracking(self):
mem = shared_memory.SharedMemory(create=True, size=10)
try:
rc, out, err = script_helper.assert_python_ok("-c", cmd, mem.name)
self.assertNotIn(b"resource_tracker", err)
self.assertEqual(rc, 0)
self.assertIn(
b"resource_tracker: There appear to be 1 leaked "
Expand Down

0 comments on commit 8255e01

Please sign in to comment.