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

Consider replacing "manual" mock classes with 'unittest.mock' versions #3509

Closed
tseaver opened this issue Jun 19, 2017 · 1 comment
Closed
Assignees
Labels
testing type: question Request for information or clarification. Not an issue.

Comments

@tseaver
Copy link
Contributor

tseaver commented Jun 19, 2017

From discussion on #3500.

There are a bunch of manually-defined stub classes in place throughout the codebase. Suggested pros for replacement:

  • mock.Mock confines to the test what the expectation is, using a format that contributors are going to be familiar with. Having to look up should not be necessary.
  • Improved / standardized assertions (assert_called_once_with and friends).

Cons:

  • Lots of churn, potentially introducing bugs.
  • DRYing out frequently-used mock setups means that users still have to go look up the helper, rather than a class: the class can be more "transparent" than the imperative setup (e.g., just add a class-scope attribute, rather than adjusting both the value passed to the mock and its scope).
@lukesneeringer
Copy link
Contributor

I want to do this, but do not particularly want to keep an open issue for it at this time.
If we want to discuss whether to do it, let's use e-mail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants