summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2023-10-31 14:16:13 -0400
committerSteve Sakoman <steve@sakoman.com>2023-11-24 05:01:37 -1000
commit52e8e9e2b6bf89f0b4ef6afa7be27fd3bfe30cb7 (patch)
tree3f5aea1cc887077db64b03186904d88f5e1d3d34
parentd1c1d93077d33f433b25bbd3bd70755c68d6d45e (diff)
downloadpoky-52e8e9e2b6bf89f0b4ef6afa7be27fd3bfe30cb7.tar.gz
patchtest: make pylint tests compatible with 3.x
pylint 3.x has removed epylint, which is now a separate module. To avoid adding another recipe or using outdated modules, modify the test_python_pylint tests so that they use the standard pylint API. (From OE-Core rev: 8b3c6837fe2367fa7aa20b2ee5be554be98f2acd) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 72be3d6a116febf46130cccbe12afe5ad93779b5) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/lib/patchtest/tests/test_python_pylint.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/meta/lib/patchtest/tests/test_python_pylint.py b/meta/lib/patchtest/tests/test_python_pylint.py
index 304b2d5ee9..ef315e591c 100644
--- a/meta/lib/patchtest/tests/test_python_pylint.py
+++ b/meta/lib/patchtest/tests/test_python_pylint.py
@@ -5,8 +5,11 @@
5# SPDX-License-Identifier: GPL-2.0-only 5# SPDX-License-Identifier: GPL-2.0-only
6 6
7import base 7import base
8from io import StringIO
8from data import PatchTestInput 9from data import PatchTestInput
9import pylint.epylint as lint 10from pylint.reporters.text import TextReporter
11import pylint.lint as lint
12
10 13
11class PyLint(base.Base): 14class PyLint(base.Base):
12 pythonpatches = [] 15 pythonpatches = []
@@ -32,8 +35,10 @@ class PyLint(base.Base):
32 def pretest_pylint(self): 35 def pretest_pylint(self):
33 for pythonpatch in self.pythonpatches: 36 for pythonpatch in self.pythonpatches:
34 if pythonpatch.is_modified_file: 37 if pythonpatch.is_modified_file:
35 (pylint_stdout, pylint_stderr) = lint.py_run(command_options = pythonpatch.path + self.pylint_options, return_std=True) 38 pylint_output = StringIO()
36 for line in pylint_stdout.readlines(): 39 reporter = TextReporter(pylint_output)
40 lint.Run([self.pylint_options, pythonpatch.path], reporter=reporter, exit=False)
41 for line in pylint_output.readlines():
37 if not '*' in line: 42 if not '*' in line:
38 if line.strip(): 43 if line.strip():
39 self.pylint_pretest[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1] 44 self.pylint_pretest[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1]
@@ -46,8 +51,10 @@ class PyLint(base.Base):
46 path = pythonpatch.target_file[2:] 51 path = pythonpatch.target_file[2:]
47 else: 52 else:
48 path = pythonpatch.path 53 path = pythonpatch.path
49 (pylint_stdout, pylint_stderr) = lint.py_run(command_options = path + self.pylint_options, return_std=True) 54 pylint_output = StringIO()
50 for line in pylint_stdout.readlines(): 55 reporter = TextReporter(pylint_output)
56 lint.Run([self.pylint_options, pythonpatch.path], reporter=reporter, exit=False)
57 for line in pylint_output.readlines():
51 if not '*' in line: 58 if not '*' in line:
52 if line.strip(): 59 if line.strip():
53 self.pylint_test[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1] 60 self.pylint_test[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1]