Merge master into features
This commit is contained in:
@@ -1102,6 +1102,38 @@ class TestFixtureUsages:
|
||||
"*Fixture 'badscope' from test_invalid_scope.py got an unexpected scope value 'functions'"
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize("scope", ["function", "session"])
|
||||
def test_parameters_without_eq_semantics(self, scope, testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
class NoEq1: # fails on `a == b` statement
|
||||
def __eq__(self, _):
|
||||
raise RuntimeError
|
||||
|
||||
class NoEq2: # fails on `if a == b:` statement
|
||||
def __eq__(self, _):
|
||||
class NoBool:
|
||||
def __bool__(self):
|
||||
raise RuntimeError
|
||||
return NoBool()
|
||||
|
||||
import pytest
|
||||
@pytest.fixture(params=[NoEq1(), NoEq2()], scope={scope!r})
|
||||
def no_eq(request):
|
||||
return request.param
|
||||
|
||||
def test1(no_eq):
|
||||
pass
|
||||
|
||||
def test2(no_eq):
|
||||
pass
|
||||
""".format(
|
||||
scope=scope
|
||||
)
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(["*4 passed*"])
|
||||
|
||||
def test_funcarg_parametrized_and_used_twice(self, testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
@@ -3662,13 +3694,30 @@ class TestParameterizedSubRequest:
|
||||
" test_foos.py::test_foo",
|
||||
"",
|
||||
"Requested fixture 'fix_with_param' defined in:",
|
||||
"*fix.py:4",
|
||||
"{}:4".format(fixfile),
|
||||
"Requested here:",
|
||||
"test_foos.py:4",
|
||||
"*1 failed*",
|
||||
]
|
||||
)
|
||||
|
||||
# With non-overlapping rootdir, passing tests_dir.
|
||||
rootdir = testdir.mkdir("rootdir")
|
||||
rootdir.chdir()
|
||||
result = testdir.runpytest("--rootdir", rootdir, tests_dir)
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"The requested fixture has no parameter defined for test:",
|
||||
" test_foos.py::test_foo",
|
||||
"",
|
||||
"Requested fixture 'fix_with_param' defined in:",
|
||||
"{}:4".format(fixfile),
|
||||
"Requested here:",
|
||||
"{}:4".format(testfile),
|
||||
"*1 failed*",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
|
||||
testdir.makeconftest(
|
||||
|
||||
Reference in New Issue
Block a user