test_testing.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """Unit tests for the included testing tools."""
  2. import pytest
  3. from reflex.constants import IS_WINDOWS
  4. from reflex.testing import AppHarness
  5. @pytest.mark.skip("Slow test that makes network requests.")
  6. def test_app_harness(tmp_path):
  7. """Ensure that AppHarness can compile and start an app.
  8. Args:
  9. tmp_path: pytest tmp_path fixture
  10. """
  11. # Skip in Windows CI.
  12. if IS_WINDOWS:
  13. return
  14. def BasicApp():
  15. import reflex as rx
  16. class State(rx.State):
  17. pass
  18. app = rx.App(state=State)
  19. app.add_page(lambda: rx.text("Basic App"), route="/", title="index")
  20. app.compile_()
  21. with AppHarness.create(
  22. root=tmp_path,
  23. app_source=BasicApp, # type: ignore
  24. ) as harness:
  25. assert harness.app_instance is not None
  26. assert harness.backend is not None
  27. assert harness.frontend_url is not None
  28. assert harness.frontend_process is not None
  29. assert harness.frontend_process.poll() is None
  30. assert harness.frontend_process.poll() is not None