-
Notifications
You must be signed in to change notification settings - Fork 352
Closed
Labels
Description
In pytest-django hooks, _setup_django() is called multiple times, in conftest setup and as a a trylast, and it leads to multiple resets of logging config (driven by django LOGGING setting).
Inbetween these calls, other plugins like pytest-capturelog try to setup their own logging handlers, but these get reset. I've monkey patched like below, but I guess _setup_django() could use a flag to prevent its multiple execution.
def pytest_configure():
# we have to prevent bug where pytest calls django.setup() multiple
# times, breaking the logging conf (and pytest-capturelog plugin)
import django.apps
if django.apps.apps.ready:
django.setup = lambda: None