Skip to content

Commit

Permalink
tests: make test_crash_on_closing_tmpfile_py27 more reliable
Browse files Browse the repository at this point in the history
It fails reliable for me now without the fix from 9517c3a.

Ref: pytest-dev#2370
  • Loading branch information
blueyed committed Mar 4, 2019
1 parent f3f6cb2 commit 83558a0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions testing/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,28 +1403,36 @@ def test_capattr():


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()


Expand Down

0 comments on commit 83558a0

Please sign in to comment.