-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
unittest.assertRegex flagged as deprecated-method #1653
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
Comments
I cannot reproduce this using the same pylint version, so not sure what exactly is going on here. Can you paste the exact output you get from pylint? |
@PCManticore I'm able to reproduce with Django==1.11.5 and pylint==1.7.4. In """d"""
from django.test import TestCase
class MyTestCase(TestCase):
"""d"""
def test_something(self):
"""d"""
self.assertRegex('string', 'other string')
def test_something_else(self):
"""d"""
self.assertRaisesRegex(ValueError, lambda: 'stuff') In your shell $ pylint --rcfile=pylint.rc check.py
************* Module check
W: 9, 8: Using deprecated method assertRegex() (deprecated-method)
W: 13, 8: Using deprecated method assertRaisesRegex() (deprecated-method)
-------------------------------------------------------------------
Your code has been rated at 6.67/10 (previous run: 10.00/10, -3.33) |
could it be because of that ? |
I ran into this issue as soon as I upgraded to Django 1.11, and a colleague too. Using pylint 1.8.1 and Python 3.5. If I remove the block https://github.com/django/django/blob/1.11.5/django/test/testcases.py#L807-L811 the warnings disappear, letting think pylint would enter the This change was indeed introduced in the 1.11 series django/django@b5f0b34 |
@PCManticore care to re-open? |
Same issue with code migrated by
|
Still the case with Python 3.6, Django 1.11.15 and Pylint 2.1.1: ************* Module tests.core.actions.test_action
tests/core/actions/test_action.py:268: [W1505(deprecated-method), ActionTestCase.test_start_action.check_call] Using deprecated method assertRegex()
tests/core/actions/test_action.py:269: [W1505(deprecated-method), ActionTestCase.test_start_action.check_call] Using deprecated method assertRegex()
tests/core/actions/test_action.py:311: [W1505(deprecated-method), ActionTestCase.test_start_action.check_call] Using deprecated method assertRegex()
tests/core/actions/test_action.py:312: [W1505(deprecated-method), ActionTestCase.test_start_action.check_call] Using deprecated method assertRegex() |
I pushed https://github.com/bors-ltd/testregex as a minimal project to reproduce the issue. You just need to launch pylint on it (with a Python 3.x venv of course). |
Yet another occurence. Using Ubuntu 18.04 with Python3.6.5 |
For Django it's definitely because of https://github.com/django/django/blob/1.11.5/django/test/testcases.py#L807-L811. I think we can make this check smarter by noticing how the method for defined, and if it's a version guard check, then we should not emit it. |
This should be fixed in the master branch, if you can do give it a try and let me know if it works for you as well. |
Steps to reproduce
Current behavior
pylint flags
unittest.assertRegex
asdeprecated-method
with Python 3.6.Expected behavior
unittest.assertRegex
is not deprecated in Python 3.6 and should not be flagged as deprecated. References:pylint --version output
The text was updated successfully, but these errors were encountered: