summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-08-22 22:37:23 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2013-08-22 22:37:23 (GMT)
commit67e5198dbf0dd184fba751540574963ace294ced (patch)
tree5a389ad370b7cf80513ff1a19d251f8207b51b18
parentfcf3b500baceda678e0fd345a8bf1d694501c740 (diff)
downloadcpython-67e5198dbf0dd184fba751540574963ace294ced.zip
cpython-67e5198dbf0dd184fba751540574963ace294ced.tar.gz
cpython-67e5198dbf0dd184fba751540574963ace294ced.tar.bz2
Make test for semaphore tracker capture and check the debug output.
-rw-r--r--Lib/test/_test_multiprocessing.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index d1c7f0b..d7e5332 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3580,16 +3580,11 @@ class TestSemaphoreTracker(unittest.TestCase):
os.write(%d, lock2._semlock.name.encode("ascii") + b"\\n")
time.sleep(10)
'''
- print("\nTestSemaphoreTracker will output warnings a bit like:\n"
- " ... There appear to be 2 leaked semaphores"
- " to clean up at shutdown\n"
- " ... '/mp-03jgqz': [Errno 2] No such file or directory",
- file=sys.stderr)
r, w = os.pipe()
p = subprocess.Popen([sys.executable,
- #'-W', 'ignore:semaphore_tracker',
'-c', cmd % (w, w)],
- pass_fds=[w])
+ pass_fds=[w],
+ stderr=subprocess.PIPE)
os.close(w)
with open(r, 'rb', closefd=True) as f:
name1 = f.readline().rstrip().decode('ascii')
@@ -3602,6 +3597,11 @@ class TestSemaphoreTracker(unittest.TestCase):
_multiprocessing.sem_unlink(name2)
# docs say it should be ENOENT, but OSX seems to give EINVAL
self.assertIn(ctx.exception.errno, (errno.ENOENT, errno.EINVAL))
+ err = p.stderr.read().decode('utf-8')
+ p.stderr.close()
+ expected = 'semaphore_tracker: There appear to be 2 leaked semaphores'
+ self.assertRegex(err, expected)
+ self.assertRegex(err, 'semaphore_tracker: %r: \[Errno' % name1)
#
# Mixins