Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

[Issue 1848] Fixing parameterized test to mock out logger to fix log pollution #1929

Merged
merged 4 commits into from
Aug 27, 2018

Conversation

EricBeach
Copy link
Contributor

No description provided.

@EricBeach
Copy link
Contributor Author

@blueandgold - I believe this is the last PR needed to fix #1848

Copy link
Contributor

@blueandgold blueandgold left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this here! A comment for a qq for my curiosity.


self.assertEqual(expect_delete_before_insert, delete_before_insert)
with mock.patch('google.cloud.forseti.enforcer.gce_firewall_enforcer.LOGGER') as mock_logger:
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this! Out of curiosity, why do we need to patch in the mock loggers this way (with with), vs at the top of the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great question. I am no Python expert, so there may be a way. However, this method, unlike the others, uses @parameterized.parameterized.expand( and I could not find a way to get the mock into those parameters. If you have a way, let me know and I'd be happy to do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, let me play around with this, and see what is happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blueandgold - any thoughts here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@EricBeach
Copy link
Contributor Author

@blueandgold - friendly ping

@EricBeach
Copy link
Contributor Author

Fixed up and much cleaner now. I must have made a small syntax error when trying the simple mock. Thanks @ahoying !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants