(self, pytester: Pytester, monkeypatch)
| 854 | assert pytester.runpytest_subprocess().ret == 0 |
| 855 | |
| 856 | def test_orphaned_pyc_file(self, pytester: Pytester, monkeypatch) -> None: |
| 857 | monkeypatch.delenv("PYTHONPYCACHEPREFIX", raising=False) |
| 858 | monkeypatch.setattr(sys, "pycache_prefix", None, raising=False) |
| 859 | |
| 860 | pytester.makepyfile( |
| 861 | """ |
| 862 | import orphan |
| 863 | def test_it(): |
| 864 | assert orphan.value == 17 |
| 865 | """ |
| 866 | ) |
| 867 | pytester.makepyfile( |
| 868 | orphan=""" |
| 869 | value = 17 |
| 870 | """ |
| 871 | ) |
| 872 | py_compile.compile("orphan.py") |
| 873 | os.remove("orphan.py") |
| 874 | |
| 875 | # Python 3 puts the .pyc files in a __pycache__ directory, and will |
| 876 | # not import from there without source. It will import a .pyc from |
| 877 | # the source location though. |
| 878 | if not os.path.exists("orphan.pyc"): |
| 879 | pycs = glob.glob("__pycache__/orphan.*.pyc") |
| 880 | assert len(pycs) == 1 |
| 881 | os.rename(pycs[0], "orphan.pyc") |
| 882 | |
| 883 | assert pytester.runpytest().ret == 0 |
| 884 | |
| 885 | def test_cached_pyc_includes_pytest_version( |
| 886 | self, pytester: Pytester, monkeypatch |
nothing calls this directly
no test coverage detected