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, and had
actually a wrong assertion in the end.

Ref: pytest-dev#2370
  • Loading branch information
blueyed committed Mar 3, 2019
1 parent f3f6cb2 commit 67bbb64
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions testing/test_capture.py
Expand Up @@ -1403,29 +1403,38 @@ 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():
global printing
f = sys.stderr
printing.set()
while True:
print('.', end='', file=f)
f.flush()
def test_silly():
global printing
t = threading.Thread(target=spam)
t.daemon = True
t.start()
time.sleep(0.5)
while not printing.isSet():
time.sleep(0.01)
"""
)
result = testdir.runpytest_subprocess()
result = testdir.runpytest_subprocess(str(p))
assert result.ret == 0
assert "IOError" not in result.stdout.str()
assert "IOError" not in result.stderr.str()


def test_pickling_and_unpickling_encoded_file():
Expand Down

0 comments on commit 67bbb64

Please sign in to comment.