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
pylint complains assertRaisesRegex is deprecated #1946
Comments
Older unittest2.TestCase (as seen in CentOS 6) do not have an assertRaisesRegex method. They only have the now-deprecated assertRaisesRegexp. We need our unit tests to work there and on newer python (3.6). Simply making assertRaisesRegex = assertRaisesRegexp makes pylint complain as described in pylint-dev/pylint#1946 . What was here before this commit was actually broken. This commit makes assertRaisesRegex functional in CentOS 6 and works around the invalid Deprecated warning from pylint. To prove this, we use assertRaisesRegex in a unit test which will be exectued in py27, py3 and py26.
For some reason the inference of the attribute |
+1 |
This should be fixed in the master branch now. |
Steps to reproduce
We have unit tests that we need to work in python 2.6 all the way to 3.6.
Older unittest2.TestCase (as seen in CentOS 6) do not have an
assertRaisesRegex method. They only have the now-deprecated
assertRaisesRegexp.
We need our unit tests to work there and on newer python (3.6),
so we just fill the method in as seen in the test case.
This causes pylint to complain that assertRaisesRegex is deprecated.
One thing to note is that we can work around this by using getattr:
Create mytest.py
Run pylint on file
Current behavior
Note that it actually complains on the use of assertRaisesRegex (not assertRaisesRegexp)
and the warning comes not from the hackery but the use of assertRaisesRegex.
Expected behavior
No errors on assertRaisesRegex are expected.
pylint --version output
The text was updated successfully, but these errors were encountered: