diff --git a/tests/test_context.py b/tests/test_context.py index 2144fc4..56c210b 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -2,6 +2,7 @@ import typing as t +import markupsafe import pytest from htpy import Context, Node, div @@ -33,6 +34,19 @@ def test_context_provider(render: RenderFixture) -> None: assert render(result) == ["
", "Hello: c!", "
"] +class Test_provider_outer_api: + """Ensure provider implements __iter__/__str__""" + + def test_iter(self) -> None: + result = letter_ctx.provider("c", lambda: div[display_letter("Hello")]) + assert list(result) == ["
", "Hello: c!", "
"] + + def test_str(self) -> None: + result = str(letter_ctx.provider("c", lambda: div[display_letter("Hello")])) + assert result == "
Hello: c!
" + assert isinstance(result, markupsafe.Markup) + + def test_no_default(render: RenderFixture) -> None: with pytest.raises( LookupError,