(
self,
pytester: Pytester,
monkeypatch: pytest.MonkeyPatch,
)
| 1140 | |
| 1141 | @pytest.mark.skipif(&class="cm">#x27;class="st">"__pypy__" in sys.modules') |
| 1142 | def test_pyc_vs_pyo( |
| 1143 | self, |
| 1144 | pytester: Pytester, |
| 1145 | monkeypatch: pytest.MonkeyPatch, |
| 1146 | ) -> None: |
| 1147 | pytester.makepyfile( |
| 1148 | class="st">""" |
| 1149 | import pytest |
| 1150 | def test_optimized(): |
| 1151 | class="st">"hello" |
| 1152 | assert test_optimized.__doc__ is Noneclass="st">""" |
| 1153 | ) |
| 1154 | p = make_numbered_dir(root=Path(pytester.path), prefix=class="st">"runpytest-") |
| 1155 | tmp = fclass="st">"--basetemp={p}" |
| 1156 | with monkeypatch.context() as mp: |
| 1157 | mp.setenv(class="st">"PYTHONOPTIMIZE", class="st">"2") |
| 1158 | mp.delenv(class="st">"PYTHONDONTWRITEBYTECODE", raising=False) |
| 1159 | mp.delenv(class="st">"PYTHONPYCACHEPREFIX", raising=False) |
| 1160 | assert pytester.runpytest_subprocess(tmp).ret == 0 |
| 1161 | tagged = class="st">"test_pyc_vs_pyo." + PYTEST_TAG |
| 1162 | assert tagged + class="st">".pyo" in os.listdir(class="st">"__pycache__") |
| 1163 | monkeypatch.delenv(class="st">"PYTHONDONTWRITEBYTECODE", raising=False) |
| 1164 | monkeypatch.delenv(class="st">"PYTHONPYCACHEPREFIX", raising=False) |
| 1165 | assert pytester.runpytest_subprocess(tmp).ret == 1 |
| 1166 | assert tagged + class="st">".pyc" in os.listdir(class="st">"__pycache__") |
| 1167 | |
| 1168 | def test_package(self, pytester: Pytester) -> None: |
| 1169 | pkg = pytester.path.joinpath(class="st">"pkg") |
nothing calls this directly
no test coverage detected