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

Method test_importmode

testing/test_doctest.py:118–142  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

116 reprec.assertoutcome(failed=1)
117
118 def test_importmode(self, pytester: Pytester):
119 pytester.makepyfile(
120 **{
121 "src/namespacepkg/innerpkg/__init__.py": "",
122 "src/namespacepkg/innerpkg/a.py": """
123 def some_func():
124 return 42
125 """,
126 "src/namespacepkg/innerpkg/b.py": """
127 from namespacepkg.innerpkg.a import some_func
128 def my_func():
129 '''
130 >>> my_func()
131 42
132 '''
133 return some_func()
134 """,
135 }
136 )
137 # For 'namespacepkg' to be considered a namespace package, its containing directory
138 # needs to be reachable from sys.path:
139 # https://packaging.python.org/en/latest/guides/packaging-namespace-packages
140 pytester.syspathinsert(pytester.path / "src")
141 reprec = pytester.inline_run("--doctest-modules", "--import-mode=importlib")
142 reprec.assertoutcome(passed=1)
143
144 def test_new_pattern(self, pytester: Pytester):
145 p = pytester.maketxtfile(

Callers

nothing calls this directly

Calls 4

assertoutcomeMethod · 0.80
makepyfileMethod · 0.45
syspathinsertMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected