-
Notifications
You must be signed in to change notification settings - Fork 5
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
Two false positives in roundup unittest TestCase #6
Comments
The last three in |
Detecting parent class That wont solve All of the violations in https://github.com/GoogleCloudPlatform/gcloud-python (mentioned in googleapis/oauth2client#328 ) are in subclasses of |
A very faulty detection of pytest would be |
And how would you want to get the parent class? It only parses one module, so it can only work if the class does only subclasses the TestCase class or classes from that module. If there should be a test specific code (what would happen to P102 and P101? Are they detected as normal and P103 only is changed) I think a more sensible solution is to specify a test path. At least the |
Can you see whether Using a test file glob might be the only sensible approach. Would yoube willing to add one as a configuration option for your plugin. IMO only P103 would be split into a separate code for 'test specific'. |
With Astroid it is possible to get information about the class MRO. >>> from astroid.test_utils import extract_node
>>> n = extract_node("""
... from unittest import TestCase
... class A(TestCase):
... def test_foo(self):
... pass
... """)
>>> print(n.mro())
[<ClassDef.A l.3 at 0x13ceb50>, <ClassDef.TestCase l.171 at 0x14430d0>, <ClassDef.object l.0 at 0xd6f290>]
>>> n.bases
[<Name.TestCase l.3 at 0x13cec10>]
>>> n.mro()[1].parent
<Module.unittest.case l.0 at 0x142b310> |
I've been testing this on a few very large repos, and finding the occasional error
In roundup (http://www.roundup-tracker.org/index.html), only the following:
test/test_templating.py:350:0: P103 other string does contain unindexed parameters
test/test_mailgw.py:2826:65: P103 other string does contain unindexed parameters
test/test_mailgw.py:2842:65: P103 other string does contain unindexed parameters
test/test_mailgw.py:2857:65: P103 other string does contain unindexed parameters
http://sourceforge.net/p/roundup/code/ci/default/tree/test/test_templating.py
http://sourceforge.net/p/roundup/code/ci/default/tree/test/test_mailgw.py
Definitely within the realms of reasonable use of noqa, but maybe worth fixing.
The text was updated successfully, but these errors were encountered: