diff options
author | Daniel Hahler <git@thequod.de> | 2019-03-03 14:06:55 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-03-04 15:04:55 +0100 |
commit | 83558a0ba3a737752deb7d0b1c78a0ef0ec0843c (patch) | |
tree | 7f22d41d5b53376ab65c7b0bcc4b442de5bccf1b /testing/test_capture.py | |
parent | f3f6cb20933c2e1e0377d5297eb35877e8781102 (diff) | |
download | pytest-83558a0ba3a737752deb7d0b1c78a0ef0ec0843c.tar.gz |
tests: make test_crash_on_closing_tmpfile_py27 more reliable
It fails reliable for me now without the fix from 9517c3a2a.
Ref: #2370
Diffstat (limited to 'testing/test_capture.py')
-rw-r--r-- | testing/test_capture.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/testing/test_capture.py b/testing/test_capture.py index 546738f28..91cf8d8cf 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1403,28 +1403,36 @@ def test_dontreadfrominput_has_encoding(testdir): def test_crash_on_closing_tmpfile_py27(testdir): - testdir.makepyfile( + p = testdir.makepyfile( """ from __future__ import print_function - import time import threading import sys + printing = threading.Event() + def spam(): f = sys.stderr + print('SPAMBEFORE', end='', file=f) + printing.set() + while True: - print('.', end='', file=f) + try: + f.flush() + except (OSError, ValueError): + break - def test_silly(): + def test_spam_in_thread(): t = threading.Thread(target=spam) t.daemon = True t.start() - time.sleep(0.5) + printing.wait() """ ) - result = testdir.runpytest_subprocess() + result = testdir.runpytest_subprocess(str(p)) assert result.ret == 0 + assert result.stderr.str() == "" assert "IOError" not in result.stdout.str() |