|
23 | 23 | from typing import TYPE_CHECKING
|
24 | 24 | from typing import Union
|
25 | 25 |
|
26 |
| -import pytest |
27 | 26 | from _pytest import outcomes
|
28 | 27 | from _pytest._code.code import ExceptionInfo
|
29 | 28 | from _pytest._code.code import ReprFileLocation
|
|
32 | 31 | from _pytest.compat import safe_getattr
|
33 | 32 | from _pytest.config import Config
|
34 | 33 | from _pytest.config.argparsing import Parser
|
| 34 | +from _pytest.fixtures import fixture |
35 | 35 | from _pytest.fixtures import FixtureRequest
|
36 | 36 | from _pytest.nodes import Collector
|
| 37 | +from _pytest.nodes import Item |
37 | 38 | from _pytest.outcomes import OutcomeException
|
| 39 | +from _pytest.outcomes import skip |
38 | 40 | from _pytest.pathlib import fnmatch_ex
|
39 | 41 | from _pytest.pathlib import import_path
|
| 42 | +from _pytest.python import Module |
40 | 43 | from _pytest.python_api import approx
|
41 | 44 | from _pytest.warning_types import PytestWarning
|
42 | 45 |
|
@@ -246,7 +249,7 @@ def _get_runner(
|
246 | 249 | )
|
247 | 250 |
|
248 | 251 |
|
249 |
| -class DoctestItem(pytest.Item): |
| 252 | +class DoctestItem(Item): |
250 | 253 | def __init__(
|
251 | 254 | self,
|
252 | 255 | name: str,
|
@@ -411,7 +414,7 @@ def _get_continue_on_failure(config):
|
411 | 414 | return continue_on_failure
|
412 | 415 |
|
413 | 416 |
|
414 |
| -class DoctestTextfile(pytest.Module): |
| 417 | +class DoctestTextfile(Module): |
415 | 418 | obj = None
|
416 | 419 |
|
417 | 420 | def collect(self) -> Iterable[DoctestItem]:
|
@@ -449,7 +452,7 @@ def _check_all_skipped(test: "doctest.DocTest") -> None:
|
449 | 452 |
|
450 | 453 | all_skipped = all(x.options.get(doctest.SKIP, False) for x in test.examples)
|
451 | 454 | if all_skipped:
|
452 |
| - pytest.skip("all tests skipped by +SKIP option") |
| 455 | + skip("all tests skipped by +SKIP option") |
453 | 456 |
|
454 | 457 |
|
455 | 458 | def _is_mocked(obj: object) -> bool:
|
@@ -491,7 +494,7 @@ def _mock_aware_unwrap(
|
491 | 494 | inspect.unwrap = real_unwrap
|
492 | 495 |
|
493 | 496 |
|
494 |
| -class DoctestModule(pytest.Module): |
| 497 | +class DoctestModule(Module): |
495 | 498 | def collect(self) -> Iterable[DoctestItem]:
|
496 | 499 | import doctest
|
497 | 500 |
|
@@ -549,7 +552,7 @@ def _find(
|
549 | 552 | )
|
550 | 553 | except ImportError:
|
551 | 554 | if self.config.getvalue("doctest_ignore_import_errors"):
|
552 |
| - pytest.skip("unable to import module %r" % self.path) |
| 555 | + skip("unable to import module %r" % self.path) |
553 | 556 | else:
|
554 | 557 | raise
|
555 | 558 | # Uses internal doctest module parsing mechanism.
|
@@ -731,7 +734,7 @@ def _get_report_choice(key: str) -> int:
|
731 | 734 | }[key]
|
732 | 735 |
|
733 | 736 |
|
734 |
| -@pytest.fixture(scope="session") |
| 737 | +@fixture(scope="session") |
735 | 738 | def doctest_namespace() -> Dict[str, Any]:
|
736 | 739 | """Fixture that returns a :py:class:`dict` that will be injected into the
|
737 | 740 | namespace of doctests.
|
|
0 commit comments