typing: Testdir.plugins

This commit is contained in:
Daniel Hahler 2020-01-27 22:56:50 +01:00
parent 94ac0f7e6b
commit 9c716e4d74
2 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,13 @@ if TYPE_CHECKING:
from typing import Type
_PluggyPlugin = object
"""A type to represent plugin objects.
Plugins can be any namespace, so we can't narrow it down much, but we use an
alias to make the intent clear.
Ideally this type would be provided by pluggy itself."""
hookimpl = HookimplMarker("pytest")
hookspec = HookspecMarker("pytest")

View File

@ -29,6 +29,7 @@ from _pytest._io.saferepr import saferepr
from _pytest.capture import MultiCapture
from _pytest.capture import SysCapture
from _pytest.compat import TYPE_CHECKING
from _pytest.config import _PluggyPlugin
from _pytest.fixtures import FixtureRequest
from _pytest.main import ExitCode
from _pytest.main import Session
@ -546,7 +547,7 @@ class Testdir:
name = request.function.__name__
self.tmpdir = tmpdir_factory.mktemp(name, numbered=True)
self.test_tmproot = tmpdir_factory.mktemp("tmp-" + name, numbered=True)
self.plugins = [] # type: ignore[var-annotated] # noqa: F821
self.plugins = [] # type: List[Union[str, _PluggyPlugin]]
self._cwd_snapshot = CwdSnapshot()
self._sys_path_snapshot = SysPathsSnapshot()
self._sys_modules_snapshot = self.__take_sys_modules_snapshot()