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

assert_ also matches assert_called_once_with() #3

Closed
The-Compiler opened this issue Jan 22, 2016 · 8 comments
Closed

assert_ also matches assert_called_once_with() #3

The-Compiler opened this issue Jan 22, 2016 · 8 comments

Comments

@The-Compiler
Copy link

When using a unittest.mock, there are certain assert_* methods to be called, e.g. m.assert_called_once_with().

Those get flagged wrongly:

D001 found assert_ replace it with assertTrue

I think this is a general problem, i.e. those matchers should only match if the full function name matches.

@gforcada
Copy link
Owner

gforcada commented Feb 4, 2016

Hi @The-Compiler sorry I didn't see this issue.

We could just extend it to be assert_(. What do you think?

@The-Compiler
Copy link
Author

sounds good to me - probably for the other matchers as well though?

@gforcada
Copy link
Owner

gforcada commented Feb 4, 2016

@The-Compiler sure, would you mind creating a pull request for it?

@The-Compiler
Copy link
Author

I'm afraid I'm involved in too much stuff and thus too busy at the moment - sorry!

(I'm also not using flake8-deprecated as I'm not using any of the libraries it checks things for - just gave it a quick try and thought I'd report this 😉)

@gforcada
Copy link
Owner

gforcada commented Feb 4, 2016

@The-Compiler sure no problem, I will try to get around doing it myself-

Thanks for reporting!

gforcada added a commit that referenced this issue Feb 27, 2016
This way no false positives are given,
like ``assert_called_once_with`` being mistakenly reported as ``assert_``
and thus asked to be replaced by ``assertTrue``

Bug reported by @The-Compiler:
#3
@gforcada
Copy link
Owner

Fixed on e4f0071

@gforcada
Copy link
Owner

@The-Compiler I released 1.0, give it a try :)

@The-Compiler
Copy link
Author

Works like a charm, thanks!

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

No branches or pull requests

2 participants