test_bare.py 627 B

12345678910111213141516171819202122232425
  1. import pytest
  2. from pynecone.components.base.bare import Bare
  3. from pynecone.state import DefaultState
  4. @pytest.mark.parametrize(
  5. "contents,expected",
  6. [
  7. ("hello", "hello"),
  8. ("{}", "{}"),
  9. ("{default_state.name}", "${default_state.name}"),
  10. ("{state.name}", "{state.name}"),
  11. ],
  12. )
  13. def test_fstrings(contents, expected):
  14. """Test that fstrings are rendered correctly.
  15. Args:
  16. contents: The contents of the component.
  17. expected: The expected output.
  18. """
  19. comp = Bare.create(contents)
  20. comp.set_state(DefaultState)
  21. assert str(comp) == f"{{`{expected}`}}"