From d22a49aebeee119a60f45d631e3a8d55fc63c3f1 Mon Sep 17 00:00:00 2001 From: Willian Antunes Date: Sun, 7 Apr 2019 16:37:57 -0300 Subject: [PATCH] As propagate is set to False, a workaround is needed to pass the tests More details at: https://github.com/eisensheng/pytest-catchlog/issues/44 --- app/tests/integration/test_signals.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/tests/integration/test_signals.py b/app/tests/integration/test_signals.py index 04f02e8..5fb826c 100644 --- a/app/tests/integration/test_signals.py +++ b/app/tests/integration/test_signals.py @@ -4,6 +4,23 @@ from django.test import Client +@pytest.yield_fixture +def caplog(caplog): + import logging + + restore = [] + for logger in logging.Logger.manager.loggerDict.values(): + try: + if not logger.propagate: + logger.propagate = True + restore += [logger] + except AttributeError: + pass + yield caplog + for logger in restore: + logger.propagate = False + + @pytest.mark.django_db def test_should_log_username_when_one_logged_in_and_logged_out(caplog: LogCaptureFixture): fake_admin_user = "fake-admin-user"