|
5 | 5 |
|
6 | 6 | import pytest
|
7 | 7 |
|
8 |
| -from pluggy import HookimplMarker |
9 | 8 | from pluggy import HookspecConfiguration
|
10 |
| -from pluggy import HookspecMarker |
11 | 9 | from pluggy import PluginManager
|
12 | 10 | from pluggy import PluginValidationError
|
| 11 | +from pluggy import ProjectSpec |
13 | 12 | from pluggy._hooks import HookCaller
|
14 | 13 | from pluggy._hooks import HookImpl
|
15 | 14 |
|
16 | 15 |
|
17 |
| -hookspec = HookspecMarker("example") |
18 |
| -hookimpl = HookimplMarker("example") |
| 16 | +project_spec = ProjectSpec("example") |
| 17 | +hookspec = project_spec.hookspec |
| 18 | +hookimpl = project_spec.hookimpl |
19 | 19 |
|
20 | 20 |
|
21 | 21 | @pytest.fixture
|
@@ -50,12 +50,14 @@ def wrap(func: FuncT) -> FuncT:
|
50 | 50 | hookwrapper=hookwrapper,
|
51 | 51 | wrapper=wrapper,
|
52 | 52 | )(func)
|
| 53 | + config = project_spec.get_hookimpl_config(func) |
| 54 | + assert config is not None # Test functions should be decorated |
53 | 55 | self.hc._add_hookimpl(
|
54 | 56 | HookImpl(
|
55 | 57 | None,
|
56 | 58 | "<temp>",
|
57 | 59 | func,
|
58 |
| - hookimpl.get_hookconfig(func), |
| 60 | + config, |
59 | 61 | ),
|
60 | 62 | )
|
61 | 63 | return func
|
@@ -549,15 +551,16 @@ def test_hookspec_configuration() -> None:
|
549 | 551 |
|
550 | 552 |
|
551 | 553 | def test_hookspec_marker_config_extraction() -> None:
|
552 |
| - """Test that HookspecMarker creates and extracts HookspecConfiguration correctly.""" |
553 |
| - marker = HookspecMarker("test") |
| 554 | + """Test that ProjectSpec can extract HookspecConfiguration correctly.""" |
| 555 | + test_project_spec = ProjectSpec("test") |
| 556 | + marker = test_project_spec.hookspec |
554 | 557 |
|
555 | 558 | @marker(firstresult=True, historic=False)
|
556 | 559 | def test_hook(arg1: str) -> str:
|
557 | 560 | return arg1
|
558 | 561 |
|
559 |
| - # Test private config extraction method |
560 |
| - config = marker._get_hookconfig(test_hook) |
| 562 | + # Test config extraction method via ProjectSpec |
| 563 | + config = test_project_spec.get_hookspec_config(test_hook) |
561 | 564 | assert isinstance(config, HookspecConfiguration)
|
562 | 565 | assert config.firstresult is True
|
563 | 566 | assert config.historic is False
|
|
0 commit comments