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,
)
| 396 | ], |
| 397 | ) |
| 398 | def test_missing_required_plugins( |
| 399 | self, |
| 400 | pytester: Pytester, |
| 401 | monkeypatch: MonkeyPatch, |
| 402 | ini_file_text: str, |
| 403 | plugin_version: str, |
| 404 | exception_text: str, |
| 405 | ) -> None: |
| 406 | """Check 'required_plugins' option with various settings. |
| 407 | |
| 408 | This test installs a mock "myplugin-1.5" which is used in the parametrized test cases. |
| 409 | """ |
| 410 | |
| 411 | @attr.s |
| 412 | class DummyEntryPoint: |
| 413 | name = attr.ib() |
| 414 | module = attr.ib() |
| 415 | group = "pytest11" |
| 416 | |
| 417 | def load(self): |
| 418 | __import__(self.module) |
| 419 | return sys.modules[self.module] |
| 420 | |
| 421 | entry_points = [ |
| 422 | DummyEntryPoint("myplugin1", "myplugin1_module"), |
| 423 | ] |
| 424 | |
| 425 | @attr.s |
| 426 | class DummyDist: |
| 427 | entry_points = attr.ib() |
| 428 | files = () |
| 429 | version = plugin_version |
| 430 | |
| 431 | @property |
| 432 | def metadata(self): |
| 433 | return {"name": "myplugin"} |
| 434 | |
| 435 | def my_dists(): |
| 436 | return [DummyDist(entry_points)] |
| 437 | |
| 438 | pytester.makepyfile(myplugin1_module="# my plugin module") |
| 439 | pytester.syspathinsert() |
| 440 | |
| 441 | monkeypatch.setattr(importlib_metadata, "distributions", my_dists) |
| 442 | monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) |
| 443 | |
| 444 | pytester.makeini(ini_file_text) |
| 445 | |
| 446 | if exception_text: |
| 447 | with pytest.raises(pytest.UsageError, match=exception_text): |
| 448 | pytester.parseconfig() |
| 449 | else: |
| 450 | pytester.parseconfig() |
| 451 | |
| 452 | def test_early_config_cmdline( |
| 453 | self, pytester: Pytester, monkeypatch: MonkeyPatch |
nothing calls this directly
no test coverage detected