Merge pull request #6285 from earonesty/patch-1
Add _pytest.fixtures.FixtureLookupError to top level import
This commit is contained in:
commit
19c243f0fa
1
AUTHORS
1
AUTHORS
|
@ -94,6 +94,7 @@ Elizaveta Shashkova
|
|||
Endre Galaczi
|
||||
Eric Hunsberger
|
||||
Eric Siegerman
|
||||
Erik Aronesty
|
||||
Erik M. Bray
|
||||
Evan Kepner
|
||||
Fabien Zarifian
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Exposed the `pytest.FixtureLookupError` exception which is raised by `request.getfixturevalue()`
|
||||
(where `request` is a `FixtureRequest` fixture) when a fixture with the given name cannot be returned.
|
|
@ -482,6 +482,9 @@ class FixtureRequest:
|
|||
But if you can only decide whether to use another fixture at test
|
||||
setup time, you may use this function to retrieve it inside a fixture
|
||||
or test function body.
|
||||
|
||||
:raise pytest.FixtureLookupError:
|
||||
If the given fixture could not be found.
|
||||
"""
|
||||
return self._get_active_fixturedef(argname).cached_result[0]
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ from _pytest.config import UsageError
|
|||
from _pytest.debugging import pytestPDB as __pytestPDB
|
||||
from _pytest.fixtures import fillfixtures as _fillfuncargs
|
||||
from _pytest.fixtures import fixture
|
||||
from _pytest.fixtures import FixtureLookupError
|
||||
from _pytest.fixtures import yield_fixture
|
||||
from _pytest.freeze_support import freeze_includes
|
||||
from _pytest.main import Session
|
||||
|
@ -62,6 +63,7 @@ __all__ = [
|
|||
"fail",
|
||||
"File",
|
||||
"fixture",
|
||||
"FixtureLookupError",
|
||||
"freeze_includes",
|
||||
"Function",
|
||||
"hookimpl",
|
||||
|
|
|
@ -3,5 +3,5 @@ import pytest
|
|||
|
||||
@pytest.fixture
|
||||
def arg1(request):
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(pytest.FixtureLookupError):
|
||||
request.getfixturevalue("arg2")
|
||||
|
|
|
@ -3,7 +3,6 @@ import textwrap
|
|||
|
||||
import pytest
|
||||
from _pytest import fixtures
|
||||
from _pytest.fixtures import FixtureLookupError
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
from _pytest.pathlib import Path
|
||||
from _pytest.pytester import get_public_names
|
||||
|
@ -654,7 +653,7 @@ class TestRequestBasic:
|
|||
)
|
||||
req = item._request
|
||||
|
||||
with pytest.raises(FixtureLookupError):
|
||||
with pytest.raises(pytest.FixtureLookupError):
|
||||
req.getfixturevalue("notexists")
|
||||
val = req.getfixturevalue("something")
|
||||
assert val == 1
|
||||
|
|
Loading…
Reference in New Issue