Merge pull request #4878 from blueyed/fix-test_crash_on_closing_tmpfile_py27
tests: make test_crash_on_closing_tmpfile_py27 more reliable
This commit is contained in:
commit
54c70bc02c
|
@ -1403,28 +1403,36 @@ def test_dontreadfrominput_has_encoding(testdir):
|
||||||
|
|
||||||
|
|
||||||
def test_crash_on_closing_tmpfile_py27(testdir):
|
def test_crash_on_closing_tmpfile_py27(testdir):
|
||||||
testdir.makepyfile(
|
p = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import time
|
|
||||||
import threading
|
import threading
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
printing = threading.Event()
|
||||||
|
|
||||||
def spam():
|
def spam():
|
||||||
f = sys.stderr
|
f = sys.stderr
|
||||||
while True:
|
print('SPAMBEFORE', end='', file=f)
|
||||||
print('.', end='', file=f)
|
printing.set()
|
||||||
|
|
||||||
def test_silly():
|
while True:
|
||||||
|
try:
|
||||||
|
f.flush()
|
||||||
|
except (OSError, ValueError):
|
||||||
|
break
|
||||||
|
|
||||||
|
def test_spam_in_thread():
|
||||||
t = threading.Thread(target=spam)
|
t = threading.Thread(target=spam)
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
|
printing.wait()
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = testdir.runpytest_subprocess()
|
result = testdir.runpytest_subprocess(str(p))
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
assert result.stderr.str() == ""
|
||||||
assert "IOError" not in result.stdout.str()
|
assert "IOError" not in result.stdout.str()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue