Check 'required_plugins' option with various settings. This test installs a mock "myplugin-1.5" which is used in the parametrized test cases.
(
self,
pytester: Pytester,
monkeypatch: MonkeyPatch,
ini_file_text: str,
plugin_version: str,
exception_text: str,
)
| 604 | ], |
| 605 | ) |
| 606 | def test_missing_required_plugins( |
| 607 | self, |
| 608 | pytester: Pytester, |
| 609 | monkeypatch: MonkeyPatch, |
| 610 | ini_file_text: str, |
| 611 | plugin_version: str, |
| 612 | exception_text: str, |
| 613 | ) -> None: |
| 614 | class="st">"""Check &class="cm">#x27;required_plugins' option with various settings. |
| 615 | |
| 616 | This test installs a mock class="st">"myplugin-1.5" which is used in the parametrized test cases. |
| 617 | class="st">""" |
| 618 | |
| 619 | @dataclasses.dataclass |
| 620 | class DummyEntryPoint: |
| 621 | name: str |
| 622 | module: str |
| 623 | group: str = class="st">"pytest11" |
| 624 | |
| 625 | def load(self): |
| 626 | return importlib.import_module(self.module) |
| 627 | |
| 628 | entry_points = [ |
| 629 | DummyEntryPoint(class="st">"myplugin1", class="st">"myplugin1_module"), |
| 630 | ] |
| 631 | |
| 632 | @dataclasses.dataclass |
| 633 | class DummyDist: |
| 634 | entry_points: object |
| 635 | files: object = () |
| 636 | version: str = plugin_version |
| 637 | |
| 638 | @property |
| 639 | def metadata(self): |
| 640 | return {class="st">"name": class="st">"myplugin"} |
| 641 | |
| 642 | def my_dists(): |
| 643 | return [DummyDist(entry_points)] |
| 644 | |
| 645 | pytester.makepyfile(myplugin1_module=class="st">"class="cm"># my plugin module") |
| 646 | pytester.syspathinsert() |
| 647 | |
| 648 | monkeypatch.setattr(importlib.metadata, class="st">"distributions", my_dists) |
| 649 | monkeypatch.delenv(class="st">"PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) |
| 650 | |
| 651 | pytester.makeini(ini_file_text) |
| 652 | |
| 653 | if exception_text: |
| 654 | with pytest.raises(pytest.UsageError, match=exception_text): |
| 655 | pytester.parseconfig() |
| 656 | else: |
| 657 | pytester.parseconfig() |
| 658 | |
| 659 | def test_early_config_cmdline( |
| 660 | self, pytester: Pytester, monkeypatch: MonkeyPatch |
nothing calls this directly
no test coverage detected