Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: make test_crash_on_closing_tmpfile_py27 more reliable #4878

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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