Staging instance, all changes can be removed at any time

Skip to content

celery_backend/config: Fix missing comma in setup_log_handler

Because of that missing comma, an exception was raised (tuple object is not callable) but it was caught and displayed by the _print_errors decorator so tests could not detect it.

As a consequence, the logging configuration of celery workers was broken.

Add a test to check if an exception was raised by the setup_log_handler function.

________________________________________________________________________________________________________________________________ test_setup_log_handler _________________________________________________________________________________________________________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x7fe797c7c7f0>

    def test_setup_log_handler(capsys):
        setup_log_handler()
        # exceptions are caught and displayed by the setup_log_handler function
        # as celery eats tracebacks in signal handler, check no traceback was
        # displayed then
>       assert "Traceback" not in capsys.readouterr().err
E       assert 'Traceback' not in ('Traceback (most recent call last):\n'\n '  File '\n '"/home/anlambert/swh/swh-environment/swh-scheduler/swh/scheduler/celery_backend/config.py", '\n 'line 53, in newf\n'\n '    return f(*args, **kwargs)\n'\n '  File '\n '"/home/anlambert/swh/swh-environment/swh-scheduler/swh/scheduler/celery_backend/config.py", '\n 'line 128, in setup_log_handler\n'\n '    ("celery", logging.INFO)\n'\n "TypeError: 'tuple' object is not callable\n")
E         'Traceback' is contained here:
E           Traceback (most recent call last):
E         ? +++++++++
E             File "/home/anlambert/swh/swh-environment/swh-scheduler/swh/scheduler/celery_backend/config.py", line 53, in newf
E               return f(*args, **kwargs)
E             File "/home/anlambert/swh/swh-environment/swh-scheduler/swh/scheduler/celery_backend/config.py", line 128, in setup_log_handler
E               ("celery", logging.INFO)
E           TypeError: 'tuple' object is not callable

swh/scheduler/tests/test_config.py:74: AssertionError

Merge request reports

Loading