diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 2a112e9c1..14428c885 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -921,7 +921,7 @@ class TerminalRepr: def __repr__(self) -> str: return "<{} instance at {:0x}>".format(self.__class__, id(self)) - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: raise NotImplementedError() @@ -932,7 +932,7 @@ class ExceptionRepr(TerminalRepr): def addsection(self, name: str, content: str, sep: str = "-") -> None: self.sections.append((name, content, sep)) - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: for name, content, sep in self.sections: tw.sep(sep, name) tw.line(content) @@ -952,7 +952,7 @@ class ExceptionChainRepr(ExceptionRepr): self.reprtraceback = chain[-1][0] self.reprcrash = chain[-1][1] - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: for element in self.chain: element[0].toterminal(tw) if element[2] is not None: @@ -969,7 +969,7 @@ class ReprExceptionInfo(ExceptionRepr): self.reprtraceback = reprtraceback self.reprcrash = reprcrash - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: self.reprtraceback.toterminal(tw) super().toterminal(tw) @@ -987,7 +987,7 @@ class ReprTraceback(TerminalRepr): self.extraline = extraline self.style = style - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: # the entries might have different styles for i, entry in enumerate(self.reprentries): if entry.style == "long": @@ -1019,7 +1019,7 @@ class ReprEntryNative(TerminalRepr): def __init__(self, tblines: Sequence[str]) -> None: self.lines = tblines - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: tw.write("".join(self.lines)) @@ -1038,7 +1038,7 @@ class ReprEntry(TerminalRepr): self.reprfileloc = filelocrepr self.style = style - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: if self.style == "short": assert self.reprfileloc is not None self.reprfileloc.toterminal(tw) @@ -1071,7 +1071,7 @@ class ReprFileLocation(TerminalRepr): self.lineno = lineno self.message = message - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: # filename and lineno output for each entry, # using an output format that most editors understand msg = self.message @@ -1086,7 +1086,7 @@ class ReprLocals(TerminalRepr): def __init__(self, lines: Sequence[str]) -> None: self.lines = lines - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: for line in self.lines: tw.line(line) @@ -1095,7 +1095,7 @@ class ReprFuncArgs(TerminalRepr): def __init__(self, args: Sequence[Tuple[str, object]]) -> None: self.args = args - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: if self.args: linesofar = "" for name, value in self.args: diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 3093ddbc8..e62c5e17e 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -13,6 +13,8 @@ from typing import Sequence from typing import Tuple from typing import Union +import py + import pytest from _pytest import outcomes from _pytest._code.code import ExceptionInfo @@ -137,7 +139,7 @@ class ReprFailDoctest(TerminalRepr): ): self.reprlocation_lines = reprlocation_lines - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: for reprlocation, lines in self.reprlocation_lines: for line in lines: tw.line(line) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 15ef3b055..e576e4cbb 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -751,7 +751,7 @@ class FixtureLookupErrorRepr(TerminalRepr): self.firstlineno = firstlineno self.argname = argname - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: # tw.line("FixtureLookupError: %s" %(self.argname), red=True) for tbline in self.tblines: tw.line(tbline.rstrip()) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index fc92ec10f..a0f180cac 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -15,6 +15,7 @@ from _pytest import nodes from _pytest.config import directory_arg from _pytest.config import hookimpl from _pytest.config import UsageError +from _pytest.fixtures import FixtureManager from _pytest.outcomes import exit from _pytest.runner import collect_one_node from _pytest.runner import SetupState @@ -377,7 +378,10 @@ class _bestrelpath_cache(dict): class Session(nodes.FSCollector): Interrupted = Interrupted Failed = Failed + # Set on the session by runner.pytest_sessionstart. _setupstate = None # type: SetupState + # Set on the session by fixtures.pytest_sessionstart. + _fixturemanager = None # type: FixtureManager def __init__(self, config): nodes.FSCollector.__init__( diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index e935dc350..3cfbf4626 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -80,7 +80,7 @@ class Node: def __init__( self, - name, + name: str, parent: Optional["Node"] = None, config: Optional[Config] = None, session: Optional["Session"] = None, diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 98876d6bf..ae5d30b3a 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -855,7 +855,7 @@ raise ValueError() from _pytest._code.code import TerminalRepr class MyRepr(TerminalRepr): - def toterminal(self, tw) -> None: + def toterminal(self, tw: py.io.TerminalWriter) -> None: tw.line("я") x = str(MyRepr())