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

Method test_ignored_virtualenvs

testing/test_collection.py:161–175  ·  view source on GitHub ↗
(self, pytester: Pytester, fname: str)

Source from the content-addressed store, hash-verified

159 ),
160 )
161 def test_ignored_virtualenvs(self, pytester: Pytester, fname: str) -> None:
162 bindir = "Scripts" if sys.platform.startswith("win") else "bin"
163 ensure_file(pytester.path / "virtual" / bindir / fname)
164 testfile = ensure_file(pytester.path / "virtual" / "test_invenv.py")
165 testfile.write_text("def test_hello(): pass")
166
167 # by default, ignore tests inside a virtualenv
168 result = pytester.runpytest()
169 result.stdout.no_fnmatch_line("*test_invenv*")
170 # allow test collection if user insists
171 result = pytester.runpytest("--collect-in-virtualenv")
172 assert "test_invenv" in result.stdout.str()
173 # allow test collection if user directly passes in the directory
174 result = pytester.runpytest("virtual")
175 assert "test_invenv" in result.stdout.str()
176
177 @pytest.mark.parametrize(
178 "fname",

Callers

nothing calls this directly

Calls 4

ensure_fileFunction · 0.85
no_fnmatch_lineMethod · 0.80
strMethod · 0.80
runpytestMethod · 0.45

Tested by

no test coverage detected