(self, pytester: Pytester, monkeypatch)
| 903 | |
| 904 | @pytest.mark.skipif('"__pypy__" in sys.modules') |
| 905 | def test_pyc_vs_pyo(self, pytester: Pytester, monkeypatch) -> None: |
| 906 | pytester.makepyfile( |
| 907 | """ |
| 908 | import pytest |
| 909 | def test_optimized(): |
| 910 | "hello" |
| 911 | assert test_optimized.__doc__ is None""" |
| 912 | ) |
| 913 | p = make_numbered_dir(root=Path(pytester.path), prefix="runpytest-") |
| 914 | tmp = "--basetemp=%s" % p |
| 915 | monkeypatch.setenv("PYTHONOPTIMIZE", "2") |
| 916 | monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False) |
| 917 | monkeypatch.delenv("PYTHONPYCACHEPREFIX", raising=False) |
| 918 | assert pytester.runpytest_subprocess(tmp).ret == 0 |
| 919 | tagged = "test_pyc_vs_pyo." + PYTEST_TAG |
| 920 | assert tagged + ".pyo" in os.listdir("__pycache__") |
| 921 | monkeypatch.undo() |
| 922 | monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False) |
| 923 | monkeypatch.delenv("PYTHONPYCACHEPREFIX", raising=False) |
| 924 | assert pytester.runpytest_subprocess(tmp).ret == 1 |
| 925 | assert tagged + ".pyc" in os.listdir("__pycache__") |
| 926 | |
| 927 | def test_package(self, pytester: Pytester) -> None: |
| 928 | pkg = pytester.path.joinpath("pkg") |
nothing calls this directly
no test coverage detected