MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_honors_pep_235

Method test_honors_pep_235

testing/test_assertrewrite.py:168–183  ·  view source on GitHub ↗
(self, pytester: Pytester, monkeypatch)

Source from the content-addressed store, hash-verified

166 result.stdout.fnmatch_lines(["*assert 1 == 2*"])
167
168 def test_honors_pep_235(self, pytester: Pytester, monkeypatch) -> None:
169 # note: couldn't make it fail on macos with a single `sys.path` entry
170 # note: these modules are named `test_*` to trigger rewriting
171 pytester.makepyfile(test_y="x = 1")
172 xdir = pytester.mkdir("x")
173 pytester.mkpydir(str(xdir.joinpath("test_Y")))
174 xdir.joinpath("test_Y").joinpath("__init__.py").write_text("x = 2")
175 pytester.makepyfile(
176 "import test_y\n"
177 "import test_Y\n"
178 "def test():\n"
179 " assert test_y.x == 1\n"
180 " assert test_Y.x == 2\n"
181 )
182 monkeypatch.syspath_prepend(str(xdir))
183 pytester.runpytest().assert_outcomes(passed=1)
184
185 def test_name(self, request) -> None:
186 def f1() -> None:

Callers

nothing calls this directly

Calls 6

syspath_prependMethod · 0.80
assert_outcomesMethod · 0.80
makepyfileMethod · 0.45
mkdirMethod · 0.45
mkpydirMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected