Merge pull request #6444 from blueyed/fix-test_xfail_handling

tests: test_xfail_handling: use sys.dont_write_bytecode
This commit is contained in:
Daniel Hahler 2020-01-17 10:28:23 +01:00 committed by GitHub
commit e16cb2fdd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -167,11 +167,13 @@ def test_stop_on_collection_errors(broken_testdir, broken_first):
result.stdout.fnmatch_lines("*error during collection*")
def test_xfail_handling(testdir):
def test_xfail_handling(testdir, monkeypatch):
"""Ensure normal xfail is ignored, and strict xfail interrupts the session in sw mode
(#5547)
"""
monkeypatch.setattr("sys.dont_write_bytecode", True)
contents = """
import pytest
def test_a(): pass
@ -205,10 +207,6 @@ def test_xfail_handling(testdir):
]
)
# because we are writing to the same file, mtime might not be affected enough to
# invalidate the cache, making this next run flaky
if testdir.tmpdir.join("__pycache__").exists():
testdir.tmpdir.join("__pycache__").remove()
testdir.makepyfile(contents.format(assert_value="0", strict="True"))
result = testdir.runpytest("--sw", "-v")
result.stdout.fnmatch_lines(