Атрибут mocked settings в pytest не работает с сигналами django post_save
Итак, ребята, Я использую pytest
Я проверил: How to mock django settings attributes in pytest-django и https://pytest-django.readthedocs.io/en/latest/helpers.html#id4 . В документации упоминается, что используя следующий подход, мы можем изменить атрибуты настроек:
def test_with_specific_settings(settings):
settings.USE_TZ = True
assert settings.USE_TZ
Таким образом, мой тестовый класс выглядит так:
@pytest.mark.django_db
class TestCase:
@pytest.fixture(autouse=True)
def _setup_endpoint(self, test_user, settings) -> None:
settings.SUSPEND_SIGNALS = True
print(settings.SUSPEND_SIGNALS) --> returns True
self.endpoint = endpoint setup
def test_create(self, test_profile) -> None:
response = self.endpoint.post(payload={})
assert response.status_code == 401
test_profile вызывает сигнал, по которому я проверяю еще раз
print(settings.SUSPEND_SIGNALS) --> returns False
Почему я получаю разные результаты? Как мне убедиться, что второй оператор печати тоже True? Я ценю вашу помощь, ребята