From f2cfce3eb9c07b84210cb6c27c5be686aad5990b Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 8 Aug 2021 20:23:27 +0200 Subject: test_py2_compat: Test the new with-statement check --- tests/pylint/test_py2_compat.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') 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(""" -- cgit 1.4.1-2-gfad0