conftest.py 652 B

123456789101112131415161718192021222324
  1. # Copyright © 2023 Ingram Micro Inc. All rights reserved.
  2. from copy import deepcopy
  3. import django
  4. import pytest
  5. @pytest.fixture(autouse=True)
  6. def restore_cqrs_settings(settings):
  7. """Adhoc solution for restoring CQRS settings after each test
  8. Pytest-Django don't track settings change for mutable objects (settings.CQRS['queue'] = ...).
  9. Fixture triggers SettingsWrapper to register change before test run and restore it after.
  10. """
  11. if hasattr(settings, 'CQRS'):
  12. settings.CQRS = deepcopy(settings.CQRS)
  13. yield
  14. @pytest.fixture()
  15. def django_v_trans_q_count_sup():
  16. return 2 if django.get_version() >= '4.2' else 0