@@ -72,6 +72,19 @@ class TestMetafunc:
|
||||
):
|
||||
metafunc.parametrize("x", [1], scope="doggy")
|
||||
|
||||
def test_parametrize_request_name(self, testdir):
|
||||
"""Show proper error when 'request' is used as a parameter name in parametrize (#6183)"""
|
||||
|
||||
def func(request):
|
||||
raise NotImplementedError()
|
||||
|
||||
metafunc = self.Metafunc(func)
|
||||
with pytest.raises(
|
||||
pytest.fail.Exception,
|
||||
match=r"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
|
||||
):
|
||||
metafunc.parametrize("request", [1])
|
||||
|
||||
def test_find_parametrized_scope(self):
|
||||
"""unittest for _find_parametrized_scope (#3941)"""
|
||||
from _pytest.python import _find_parametrized_scope
|
||||
|
||||
@@ -1262,3 +1262,24 @@ def test_collector_respects_tbstyle(testdir):
|
||||
"*= 1 error in *",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_does_not_eagerly_collect_packages(testdir):
|
||||
testdir.makepyfile("def test(): pass")
|
||||
pydir = testdir.mkpydir("foopkg")
|
||||
pydir.join("__init__.py").write("assert False")
|
||||
result = testdir.runpytest()
|
||||
assert result.ret == ExitCode.OK
|
||||
|
||||
|
||||
def test_does_not_put_src_on_path(testdir):
|
||||
# `src` is not on sys.path so it should not be importable
|
||||
testdir.tmpdir.join("src/nope/__init__.py").ensure()
|
||||
testdir.makepyfile(
|
||||
"import pytest\n"
|
||||
"def test():\n"
|
||||
" with pytest.raises(ImportError):\n"
|
||||
" import nope\n"
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
assert result.ret == ExitCode.OK
|
||||
|
||||
Reference in New Issue
Block a user