Show More
@@ -142,6 +142,23 def pytest_collect_file( | |||||
142 | return None |
|
142 | return None | |
143 |
|
143 | |||
144 |
|
144 | |||
|
145 | if int(pytest.__version__.split(".")[0]) < 7: | |||
|
146 | _collect_file = pytest_collect_file | |||
|
147 | ||||
|
148 | def pytest_collect_file( | |||
|
149 | path, | |||
|
150 | parent: Collector, | |||
|
151 | ) -> Optional[Union["IPDoctestModule", "IPDoctestTextfile"]]: | |||
|
152 | return _collect_file(Path(path), parent) | |||
|
153 | ||||
|
154 | _import_path = import_path | |||
|
155 | ||||
|
156 | def import_path(path, root): | |||
|
157 | import py.path | |||
|
158 | ||||
|
159 | return _import_path(py.path.local(path)) | |||
|
160 | ||||
|
161 | ||||
145 | def _is_setup_py(path: Path) -> bool: |
|
162 | def _is_setup_py(path: Path) -> bool: | |
146 | if path.name != "setup.py": |
|
163 | if path.name != "setup.py": | |
147 | return False |
|
164 | return False | |
@@ -427,6 +444,12 class IPDoctestItem(pytest.Item): | |||||
427 | assert self.dtest is not None |
|
444 | assert self.dtest is not None | |
428 | return self.path, self.dtest.lineno, "[ipdoctest] %s" % self.name |
|
445 | return self.path, self.dtest.lineno, "[ipdoctest] %s" % self.name | |
429 |
|
446 | |||
|
447 | if int(pytest.__version__.split(".")[0]) < 7: | |||
|
448 | ||||
|
449 | @property | |||
|
450 | def path(self) -> Path: | |||
|
451 | return Path(self.fspath) | |||
|
452 | ||||
430 |
|
453 | |||
431 | def _get_flag_lookup() -> Dict[str, int]: |
|
454 | def _get_flag_lookup() -> Dict[str, int]: | |
432 | import doctest |
|
455 | import doctest | |
@@ -494,6 +517,27 class IPDoctestTextfile(pytest.Module): | |||||
494 | self, name=test.name, runner=runner, dtest=test |
|
517 | self, name=test.name, runner=runner, dtest=test | |
495 | ) |
|
518 | ) | |
496 |
|
519 | |||
|
520 | if int(pytest.__version__.split(".")[0]) < 7: | |||
|
521 | ||||
|
522 | @property | |||
|
523 | def path(self) -> Path: | |||
|
524 | return Path(self.fspath) | |||
|
525 | ||||
|
526 | @classmethod | |||
|
527 | def from_parent( | |||
|
528 | cls, | |||
|
529 | parent, | |||
|
530 | *, | |||
|
531 | fspath=None, | |||
|
532 | path: Optional[Path] = None, | |||
|
533 | **kw, | |||
|
534 | ): | |||
|
535 | if path is not None: | |||
|
536 | import py.path | |||
|
537 | ||||
|
538 | fspath = py.path.local(path) | |||
|
539 | return super().from_parent(parent=parent, fspath=fspath, **kw) | |||
|
540 | ||||
497 |
|
541 | |||
498 | def _check_all_skipped(test: "doctest.DocTest") -> None: |
|
542 | def _check_all_skipped(test: "doctest.DocTest") -> None: | |
499 | """Raise pytest.skip() if all examples in the given DocTest have the SKIP |
|
543 | """Raise pytest.skip() if all examples in the given DocTest have the SKIP | |
@@ -589,6 +633,12 class IPDoctestModule(pytest.Module): | |||||
589 | ) |
|
633 | ) | |
590 |
|
634 | |||
591 | if self.path.name == "conftest.py": |
|
635 | if self.path.name == "conftest.py": | |
|
636 | if int(pytest.__version__.split(".")[0]) < 7: | |||
|
637 | module = self.config.pluginmanager._importconftest( | |||
|
638 | self.path, | |||
|
639 | self.config.getoption("importmode"), | |||
|
640 | ) | |||
|
641 | else: | |||
592 | module = self.config.pluginmanager._importconftest( |
|
642 | module = self.config.pluginmanager._importconftest( | |
593 | self.path, |
|
643 | self.path, | |
594 | self.config.getoption("importmode"), |
|
644 | self.config.getoption("importmode"), | |
@@ -618,6 +668,27 class IPDoctestModule(pytest.Module): | |||||
618 | self, name=test.name, runner=runner, dtest=test |
|
668 | self, name=test.name, runner=runner, dtest=test | |
619 | ) |
|
669 | ) | |
620 |
|
670 | |||
|
671 | if int(pytest.__version__.split(".")[0]) < 7: | |||
|
672 | ||||
|
673 | @property | |||
|
674 | def path(self) -> Path: | |||
|
675 | return Path(self.fspath) | |||
|
676 | ||||
|
677 | @classmethod | |||
|
678 | def from_parent( | |||
|
679 | cls, | |||
|
680 | parent, | |||
|
681 | *, | |||
|
682 | fspath=None, | |||
|
683 | path: Optional[Path] = None, | |||
|
684 | **kw, | |||
|
685 | ): | |||
|
686 | if path is not None: | |||
|
687 | import py.path | |||
|
688 | ||||
|
689 | fspath = py.path.local(path) | |||
|
690 | return super().from_parent(parent=parent, fspath=fspath, **kw) | |||
|
691 | ||||
621 |
|
692 | |||
622 | def _setup_fixtures(doctest_item: IPDoctestItem) -> FixtureRequest: |
|
693 | def _setup_fixtures(doctest_item: IPDoctestItem) -> FixtureRequest: | |
623 | """Used by IPDoctestTextfile and IPDoctestItem to setup fixture information.""" |
|
694 | """Used by IPDoctestTextfile and IPDoctestItem to setup fixture information.""" |
General Comments 0
You need to be logged in to leave comments.
Login now