test_collection.py migrate from testdir to Pytester (#8003)

This commit is contained in:
Sanket Duthade 2020-11-07 20:26:00 +05:30 committed by GitHub
parent 6a5037a25b
commit 3bcd316f07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 376 additions and 347 deletions

View File

@ -50,7 +50,6 @@ from _pytest.monkeypatch import MonkeyPatch
from _pytest.nodes import Collector from _pytest.nodes import Collector
from _pytest.nodes import Item from _pytest.nodes import Item
from _pytest.pathlib import make_numbered_dir from _pytest.pathlib import make_numbered_dir
from _pytest.python import Module
from _pytest.reports import CollectReport from _pytest.reports import CollectReport
from _pytest.reports import TestReport from _pytest.reports import TestReport
from _pytest.tmpdir import TempPathFactory from _pytest.tmpdir import TempPathFactory
@ -652,7 +651,7 @@ class Pytester:
) -> None: ) -> None:
self._request = request self._request = request
self._mod_collections: WeakKeyDictionary[ self._mod_collections: WeakKeyDictionary[
Module, List[Union[Item, Collector]] Collector, List[Union[Item, Collector]]
] = (WeakKeyDictionary()) ] = (WeakKeyDictionary())
if request.function: if request.function:
name: str = request.function.__name__ name: str = request.function.__name__
@ -1244,7 +1243,7 @@ class Pytester:
return self.getnode(config, path) return self.getnode(config, path)
def collect_by_name( def collect_by_name(
self, modcol: Module, name: str self, modcol: Collector, name: str
) -> Optional[Union[Item, Collector]]: ) -> Optional[Union[Item, Collector]]:
"""Return the collection node for name from the module collection. """Return the collection node for name from the module collection.
@ -1639,7 +1638,7 @@ class Testdir:
) )
def collect_by_name( def collect_by_name(
self, modcol: Module, name: str self, modcol: Collector, name: str
) -> Optional[Union[Item, Collector]]: ) -> Optional[Union[Item, Collector]]:
"""See :meth:`Pytester.collect_by_name`.""" """See :meth:`Pytester.collect_by_name`."""
return self._pytester.collect_by_name(modcol, name) return self._pytester.collect_by_name(modcol, name)

File diff suppressed because it is too large Load Diff