[Python-checkins] cpython: Make test for semaphore tracker capture and check the debug output.
richard.oudkerk
python-checkins at python.org
Fri Aug 23 00:39:34 CEST 2013
http://hg.python.org/cpython/rev/d51486f8ac08
changeset: 85330:d51486f8ac08
user: Richard Oudkerk <shibturn at gmail.com>
date: Thu Aug 22 23:37:23 2013 +0100
summary:
Make test for semaphore tracker capture and check the debug output.
files:
Lib/test/_test_multiprocessing.py | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3580,16 +3580,11 @@
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 @@
_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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list