Skip to content

Commit f6b675d

Browse files
committed
Fix failing tests caused by new flag feature
1 parent ff8957d commit f6b675d

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

test/conftest.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from fnmatch import fnmatch
22
from pathlib import Path
3-
from typing import Any, cast
3+
from typing import Any
44

55
import pytest
66
from hexdoc.core.properties import Properties
@@ -40,13 +40,18 @@ def path_snapshot(snapshot: SnapshotAssertion):
4040

4141

4242
@pytest.fixture
43-
def pm():
44-
return PluginManager(branch="main", props=cast(Properties, None))
43+
def pm_props():
44+
return Properties.model_construct(flags={})
4545

4646

4747
@pytest.fixture
48-
def empty_pm():
49-
return PluginManager(branch="main", props=cast(Properties, None), load=False)
48+
def pm(pm_props: Properties):
49+
return PluginManager(branch="main", props=pm_props)
50+
51+
52+
@pytest.fixture
53+
def empty_pm(pm_props: Properties):
54+
return PluginManager(branch="main", props=pm_props, load=False)
5055

5156

5257
@pytest.fixture(scope="session")

test/patchouli/test_page.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1+
from typing import Any
2+
3+
import pytest
4+
from hexdoc.patchouli.book_context import BookContext
15
from hexdoc.patchouli.page import EmptyPage, Page
26
from hexdoc.plugin import PluginManager
37

48

5-
def test_empty_page(pm: PluginManager):
9+
@pytest.fixture
10+
def context(pm: PluginManager):
11+
return {
12+
pm.context_key: pm,
13+
BookContext.context_key: BookContext.model_construct(flags={}),
14+
}
15+
16+
17+
def test_empty_page(context: dict[str, Any]):
618
data = {
719
"type": "patchouli:empty",
820
}
9-
context = {pm.context_key: pm}
1021

1122
page = Page.model_validate(data, context=context)
1223

1324
assert isinstance(page, EmptyPage)
1425

1526

16-
def test_use_default_patchouli_namespace(pm: PluginManager):
27+
def test_use_default_patchouli_namespace(context: dict[str, Any]):
1728
data = {
1829
"type": "empty",
1930
}
20-
context = {pm.context_key: pm}
2131

2232
page = Page.model_validate(data, context=context)
2333

0 commit comments

Comments
 (0)