So guys, I am using pytest
I have checked: How to mock django settings attributes in pytest-django and https://pytest-django.readthedocs.io/en/latest/helpers.html#id4 . The docs mention that using following approach we can alter settings attributes:
def test_with_specific_settings(settings):
settings.USE_TZ = True
assert settings.USE_TZ
Thus my test class looks like:
@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 triggers a signal where I check again
print(settings.SUSPEND_SIGNALS) --> returns False
Why do I get different results? How do I make sure that second print statement is also True? I appreciate your help guys