conftest.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Shared conftest for all integration tests."""
  2. import pytest
  3. import reflex.app
  4. from reflex.testing import AppHarness, AppHarnessProd
  5. @pytest.fixture(
  6. scope="session", params=[AppHarness, AppHarnessProd], ids=["dev", "prod"]
  7. )
  8. def app_harness_env(request):
  9. """Parametrize the AppHarness class to use for the test, either dev or prod.
  10. Args:
  11. request: The pytest fixture request object.
  12. Returns:
  13. The AppHarness class to use for the test.
  14. """
  15. return request.param
  16. @pytest.fixture(autouse=True)
  17. def raise_console_error(request, mocker):
  18. """Spy on calls to `console.error` used by the framework.
  19. Help catch spurious error conditions that might otherwise go unnoticed.
  20. If a test is marked with `ignore_console_error`, the spy will be ignored
  21. after the test.
  22. Args:
  23. request: The pytest request object.
  24. mocker: The pytest mocker object.
  25. Yields:
  26. control to the test function.
  27. """
  28. spy = mocker.spy(reflex.app.console, "error")
  29. yield
  30. if "ignore_console_error" not in request.keywords:
  31. spy.assert_not_called()