Include pytest version in the cached pyc tags (#5484)

Include pytest version in the cached pyc tags
This commit is contained in:
Bruno Oliveira
2019-06-25 12:07:01 -03:00
committed by GitHub
3 changed files with 22 additions and 1 deletions
+18
View File
@@ -780,6 +780,24 @@ def test_rewritten():
assert testdir.runpytest().ret == 0
def test_cached_pyc_includes_pytest_version(self, testdir, monkeypatch):
"""Avoid stale caches (#1671)"""
monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False)
testdir.makepyfile(
test_foo="""
def test_foo():
assert True
"""
)
result = testdir.runpytest_subprocess()
assert result.ret == 0
found_names = glob.glob(
"__pycache__/*-pytest-{}.pyc".format(pytest.__version__)
)
assert found_names, "pyc with expected tag not found in names: {}".format(
glob.glob("__pycache__/*.pyc")
)
@pytest.mark.skipif('"__pypy__" in sys.modules')
def test_pyc_vs_pyo(self, testdir, monkeypatch):
testdir.makepyfile(