diff options
author | toonn <toonn@toonn.io> | 2021-08-08 20:23:27 +0200 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2021-08-08 20:23:27 +0200 |
commit | f2cfce3eb9c07b84210cb6c27c5be686aad5990b (patch) | |
tree | 4ed324d41e48a05459ca3326262b5eef68f6ba3b /tests | |
parent | 1f5a23a8162f695abaee062558d9b609a3f4366a (diff) | |
download | ranger-f2cfce3eb9c07b84210cb6c27c5be686aad5990b.tar.gz |
test_py2_compat: Test the new with-statement check
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pylint/test_py2_compat.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/pylint/test_py2_compat.py b/tests/pylint/test_py2_compat.py index bd1ace65..7156aba7 100644 --- a/tests/pylint/test_py2_compat.py +++ b/tests/pylint/test_py2_compat.py @@ -115,6 +115,32 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): ): self.checker.visit_call(implicit_format_spec) + def test_with_Popen(self): + with_subprocess_Popen, with_Popen, with_Popen23 = astroid.extract_node(""" + import subprocess + with subprocess.Popen(): #@ + pass + + from subprocess import Popen + with Popen(): #@ + pass + + from ranger.ext.popen23 import Popen23 + with Popen23(): #@ + pass + """) + + with self.assertAddsMessages( + pylint.testutils.Message( + msg_id='with-popen23', + node=with_Popen, + ), + ): + self.checker.visit_with(with_subprocess_Popen) + self.checker.visit_with(with_Popen) + with self.assertNoMessages(): + self.checker.visit_with(with_Popen23) + # # These checks still exist as old-division and no-absolute-import # def test_division_without_import(self): # division = astroid.extract_node(""" |