You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@pytest.fixture(scope="session")
def session_settings():
"""A Django settings object which restores changes after the test session"""
skip_if_no_django()
wrapper = SettingsWrapper()
yield wrapper
wrapper.finalize()
Unfortunately it's not, because SettingsWrapper._to_restore is a class attributes, rather than an instance attribute. So if you have any of the original settings fixture in your code, when those call finalize, they'll remove your session-scoped settings changes, too.
This should be an easy fix, tho: just make SettingsWrapper._to_restore an instance attribute, so that there can be multiple different SettingsWrappers in use at the same time, without interfering with each other.
The text was updated successfully, but these errors were encountered:
I wish it was as easy as this:
Unfortunately it's not, because
SettingsWrapper._to_restore
is a class attributes, rather than an instance attribute. So if you have any of the originalsettings
fixture in your code, when those call finalize, they'll remove your session-scoped settings changes, too.This should be an easy fix, tho: just make
SettingsWrapper._to_restore
an instance attribute, so that there can be multiple different SettingsWrappers in use at the same time, without interfering with each other.The text was updated successfully, but these errors were encountered: