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

Method test_import_duplicate

testing/python/collect.py:23–43  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

21 pytest.raises(Collector.CollectError, modcol.collect)
22
23 def test_import_duplicate(self, pytester: Pytester) -> None:
24 a = pytester.mkdir("a")
25 b = pytester.mkdir("b")
26 p1 = a.joinpath("test_whatever.py")
27 p1.touch()
28 p2 = b.joinpath("test_whatever.py")
29 p2.touch()
30 # ensure we don't have it imported already
31 sys.modules.pop(p1.stem, None)
32
33 result = pytester.runpytest()
34 result.stdout.fnmatch_lines(
35 [
36 "*import*mismatch*",
37 "*imported*test_whatever*",
38 "*%s*" % p1,
39 "*not the same*",
40 "*%s*" % p2,
41 "*HINT*",
42 ]
43 )
44
45 def test_import_prepend_append(
46 self, pytester: Pytester, monkeypatch: MonkeyPatch

Callers

nothing calls this directly

Calls 4

popMethod · 0.80
fnmatch_linesMethod · 0.80
mkdirMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected