Skip to content

Commit

Permalink
fix: check that importing a non-compliant render module throws an error
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Sep 9, 2024
1 parent 7ae5a7a commit 2a2d790
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/_lib/nonfrender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Testing example renderer.
Correctly fails to import to show a broken module being handled.
"""

from typing import Unpack, TypedDict
from dewret.workflow import Workflow

from .extra import JUMP

class NonfrenderRendererConfiguration(TypedDict):
allow_complex_types: bool

# This should fail to load as default_config is not present. However it would
# ignore the fact that the return type is not a (subtype of) dict[str, RawType]
# def default_config() -> int:
# return 3

def render_raw(
workflow: Workflow, **kwargs: Unpack[NonfrenderRendererConfiguration]
) -> dict[str, str]:
return {"JUMP": str(JUMP)}
6 changes: 6 additions & 0 deletions tests/test_render_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ def test_get_correct_import_error_if_unable_to_load_render_module() -> None:
).resolve()
assert entry.relline == 2
assert "attempted relative import with no known parent package" in str(exc.value)

nonfrender_py = Path(__file__).parent / "_lib/nonfrender.py"
with pytest.raises(NotImplementedError) as nexc:
get_render_method(nonfrender_py)

assert "This render module neither seems to be a structured nor a raw render module" in str(nexc.value)

0 comments on commit 2a2d790

Please sign in to comment.