conftest.py 1.1 KB

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