MCPcopy
hub / github.com/pytest-dev/pytest / test_honors_pep_235

Method test_honors_pep_235

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

Source from the content-addressed store, hash-verified

373 result.stdout.fnmatch_lines(["*assert 1 == 2*"])
374
375 def test_honors_pep_235(self, pytester: Pytester, monkeypatch) -> None:
376 # note: couldn't make it fail on macos with a single `sys.path` entry
377 # note: these modules are named `test_*` to trigger rewriting
378 pytester.makepyfile(test_y="x = 1")
379 xdir = pytester.mkdir("x")
380 pytester.mkpydir(str(xdir.joinpath("test_Y")))
381 xdir.joinpath("test_Y").joinpath("__init__.py").write_text(
382 "x = 2", encoding="utf-8"
383 )
384 pytester.makepyfile(
385 "import test_y\n"
386 "import test_Y\n"
387 "def test():\n"
388 " assert test_y.x == 1\n"
389 " assert test_Y.x == 2\n"
390 )
391 monkeypatch.syspath_prepend(str(xdir))
392 pytester.runpytest().assert_outcomes(passed=1)
393
394 def test_name(self, request) -> None:
395 def f1() -> None:

Callers

nothing calls this directly

Calls 7

write_textMethod · 0.80
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