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
From the docs:
The test passes if at least one message emitted inside the with block matches the logger and level conditions, otherwise it fails.
This means that this test should fail (nothing has been logged at warning level or above), but it passes.
The reason is that in the assertLogs context manager, the log level of the passed logger is temporarily set to the passed level, and if no logging has happened on exit, the test will fail.
If no logger is passed into the call, the temporary log level is set in the root level. If any descendant logger has it's own log level set (as in this example to INFO), this logger will still log at it's own level, and the test will pass.
This will always happen on the condition that a descendent of the passed logger has it's own log level set that is smaller than the asserted level, and it does some logging at this level inside the assertLog context manager.