Fix flakey test test_disable_logging#26871
Merged
Merged
Conversation
We expected an AssertionError arising from `self.assertLogs`, which means we expected that no logs would be emitted. The problem is, when this fails, we don't know why -- we don't know what was logged that we did not expect to be logged. We can improve this test by capturing the logs, then asserting that the logs captured are only the ones emitted explicitly in the test code (assertLogs will fail if we don't insert a dummy log record).
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
jedcunningham
approved these changes
Oct 4, 2022
kaxil
approved these changes
Oct 4, 2022
potiuk
approved these changes
Oct 4, 2022
blag
approved these changes
Oct 4, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We expected an AssertionError arising from
self.assertLogs, which means we expected that no logs would be emitted.The problem is, when this fails, we don't know why -- we don't know what was logged that we did not expect to be logged.
We can improve this test by capturing the logs, then asserting that the logs captured are only the ones emitted explicitly in the test code (assertLogs will fail if we don't insert a dummy log record).