typing: minor improvements

This commit is contained in:
Daniel Hahler 2019-11-24 23:20:03 +01:00
parent d7d5cf4136
commit bc7282576f
2 changed files with 6 additions and 6 deletions

View File

@ -36,6 +36,7 @@ if False: # TYPE_CHECKING
from typing import Type from typing import Type
from _pytest import nodes from _pytest import nodes
from _pytest.main import Session
@attr.s(frozen=True) @attr.s(frozen=True)
@ -44,7 +45,7 @@ class PseudoFixtureDef:
scope = attr.ib() scope = attr.ib()
def pytest_sessionstart(session): def pytest_sessionstart(session: "Session"):
import _pytest.python import _pytest.python
import _pytest.nodes import _pytest.nodes
@ -510,13 +511,11 @@ class FixtureRequest:
values.append(fixturedef) values.append(fixturedef)
current = current._parent_request current = current._parent_request
def _compute_fixture_value(self, fixturedef): def _compute_fixture_value(self, fixturedef: "FixtureDef") -> None:
""" """
Creates a SubRequest based on "self" and calls the execute method of the given fixturedef object. This will Creates a SubRequest based on "self" and calls the execute method of the given fixturedef object. This will
force the FixtureDef object to throw away any previous results and compute a new fixture value, which force the FixtureDef object to throw away any previous results and compute a new fixture value, which
will be stored into the FixtureDef object itself. will be stored into the FixtureDef object itself.
:param FixtureDef fixturedef:
""" """
# prepare a subrequest object before calling fixture function # prepare a subrequest object before calling fixture function
# (latter managed by fixturedef) # (latter managed by fixturedef)
@ -544,9 +543,8 @@ class FixtureRequest:
if has_params: if has_params:
frame = inspect.stack()[3] frame = inspect.stack()[3]
frameinfo = inspect.getframeinfo(frame[0]) frameinfo = inspect.getframeinfo(frame[0])
source_path = frameinfo.filename source_path = py.path.local(frameinfo.filename)
source_lineno = frameinfo.lineno source_lineno = frameinfo.lineno
source_path = py.path.local(source_path)
if source_path.relto(funcitem.config.rootdir): if source_path.relto(funcitem.config.rootdir):
source_path = source_path.relto(funcitem.config.rootdir) source_path = source_path.relto(funcitem.config.rootdir)
msg = ( msg = (

View File

@ -15,6 +15,7 @@ from _pytest import nodes
from _pytest.config import directory_arg from _pytest.config import directory_arg
from _pytest.config import hookimpl from _pytest.config import hookimpl
from _pytest.config import UsageError from _pytest.config import UsageError
from _pytest.fixtures import FixtureManager
from _pytest.outcomes import exit from _pytest.outcomes import exit
from _pytest.runner import collect_one_node from _pytest.runner import collect_one_node
from _pytest.runner import SetupState from _pytest.runner import SetupState
@ -372,6 +373,7 @@ class Session(nodes.FSCollector):
Interrupted = Interrupted Interrupted = Interrupted
Failed = Failed Failed = Failed
_setupstate = None # type: SetupState _setupstate = None # type: SetupState
_fixturemanager = None # type: FixtureManager
def __init__(self, config): def __init__(self, config):
nodes.FSCollector.__init__( nodes.FSCollector.__init__(