diff --git a/tests/components/core/test_cond.py b/tests/components/core/test_cond.py index a98a68f41..e3fc40ae3 100644 --- a/tests/components/core/test_cond.py +++ b/tests/components/core/test_cond.py @@ -58,11 +58,7 @@ def test_validate_cond(cond_state: BaseState): [true_value_text] = true_value["children"] assert true_value_text["name"] == "RadixThemesText" - assert true_value_text["children"][0]["contents"] in ( - "{`cond is True`}", - '{"cond is True"}', - "{'cond is True'}", - ) + assert true_value_text["children"][0]["contents"] == '{"cond is True"}' # false value false_value = condition["false_value"] @@ -70,11 +66,7 @@ def test_validate_cond(cond_state: BaseState): [false_value_text] = false_value["children"] assert false_value_text["name"] == "RadixThemesText" - assert false_value_text["children"][0]["contents"] in ( - "{`cond is False`}", - '{"cond is False"}', - "{'cond is False'}", - ) + assert false_value_text["children"][0]["contents"] == '{"cond is False"}' @pytest.mark.parametrize( diff --git a/tests/components/core/test_html.py b/tests/components/core/test_html.py index 9c1a0c28d..1fa2bcf75 100644 --- a/tests/components/core/test_html.py +++ b/tests/components/core/test_html.py @@ -1,6 +1,7 @@ import pytest from reflex.components.core.html import Html +from reflex.state import State def test_html_no_children(): @@ -20,3 +21,21 @@ def test_html_create(): str(html) == '
Hello !

" })}/>' ) + + +def test_html_fstring_create(): + class TestState(State): + """The app state.""" + + myvar: str = "Blue" + + html = Html.create(f"

Hello {TestState.myvar}!

") + + assert ( + str(html.dangerouslySetInnerHTML) + == f'({{ ["__html"] : ("

Hello "+{str(TestState.myvar)}+"!

") }})' + ) + assert ( + str(html) + == f'
' + )