[Python-checkins] bpo-38018: Fix test for multiprocessing.shared_memory in BSD systems (GH-15821)

Pablo Galindo webhook-mailer at python.org
Tue Sep 10 02:48:31 EDT 2019


https://github.com/python/cpython/commit/2fc1160a80733f4c5c88796319154b3f59e98e4b
commit: 2fc1160a80733f4c5c88796319154b3f59e98e4b
branch: master
author: Vinay Sharma <vinay04sharma at icloud.com>
committer: Pablo Galindo <Pablogsal at gmail.com>
date: 2019-09-10T07:48:24+01:00
summary:

bpo-38018: Fix test for multiprocessing.shared_memory in BSD systems (GH-15821)

files:
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 8269b879eb9d..c717d0aad287 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3732,16 +3732,21 @@ def test_shared_memory_basics(self):
         with unittest.mock.patch(
             'multiprocessing.shared_memory._make_filename') as mock_make_filename:
 
+            NAME_PREFIX = shared_memory._SHM_NAME_PREFIX
             names = ['test01_fn', 'test02_fn']
+            # Prepend NAME_PREFIX which can be '/psm_' or 'wnsm_', necessary
+            # because some POSIX compliant systems require name to start with /
+            names = [NAME_PREFIX + name for name in names]
+
             mock_make_filename.side_effect = names
             shm1 = shared_memory.SharedMemory(create=True, size=1)
             self.addCleanup(shm1.unlink)
-            self.assertEqual(shm1.name, names[0])
+            self.assertEqual(shm1._name, names[0])
 
             mock_make_filename.side_effect = names
             shm2 = shared_memory.SharedMemory(create=True, size=1)
             self.addCleanup(shm2.unlink)
-            self.assertEqual(shm2.name, names[1])
+            self.assertEqual(shm2._name, names[1])
 
         if shared_memory._USE_POSIX:
             # Posix Shared Memory can only be unlinked once.  Here we



More information about the Python-checkins mailing list