Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace remaining logging mocks with assertLogs. #19392

Merged
merged 5 commits into from Jul 26, 2021

Conversation

chdinesh1089
Copy link
Collaborator

Closes #15331

I think this completes the migration of logging mocks to assertLogs. The ones left are either used to assert a logging call isn't made, or some sort of strategic mocking like this, or somehow necessary for eg. to check stack_info is set True.

We were disabling push_notifications logger but weren't enabling
it back. This caused failures on porting logging mocks to assertLogs
as assertLogs expects a log to be generated.

See 9c224cc for why we disable
these. (To avoid logs spam from push_notifications_logger)
Left the mocks which are used to assert a logging call isn't made.
@zulipbot
Copy link
Member

Hello @chdinesh1089, it seems like you have referenced #15331 in your pull request description, but you have not referenced them in your commit message description(s). When you reference an issue in a commit message, it automatically closes the corresponding issue when the commit is merged.

Please run git commit --amend in your command line client to amend your commit message description with Fixes #15331..

An example of a correctly-formatted commit:

commit fabd5e450374c8dde65ec35f02140383940fe146
Author: zulipbot
Date:   Sat Mar 18 13:42:40 2017 -0700

    pull requests: Check PR commits reference when issue is referenced.

    Fixes #51.

Thank you for your contributions to Zulip!

Set level to 'ERROR' since exceptions create logs with that level.
Of the two other logging mocks left in this file, one checks
a logging call isn't made and another makes sure errors
aren't allowed by raising an exception as a side_effect
to the logger.
@@ -899,6 +898,8 @@ def handle(self, **options: Any) -> None:
mark_all_messages_as_read()
self.stdout.write("Successfully populated test database.\n")

push_notifications_logger.disabled = False
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think probably the important part is just moving this out of the top level, so that importing this file doesn't result in that change occurring.

@timabbott timabbott merged commit beadb5e into zulip:master Jul 26, 2021
@timabbott
Copy link
Sponsor Member

This is awesome, merged, thanks @chdinesh1089!

@chdinesh1089 chdinesh1089 deleted the assertLogs branch July 27, 2021 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate all backend tests to use assertLogs.
3 participants