aboutsummaryrefslogtreecommitdiffstats
path: root/packaging-tools/tests
diff options
context:
space:
mode:
authorPatrik Teivonen <patrik.teivonen@qt.io>2022-07-05 14:19:26 +0300
committerPatrik Teivonen <patrik.teivonen@qt.io>2022-09-11 21:39:07 +0000
commit6eb9237645e0ad29afa699b714840eaf338266e2 (patch)
tree43f88073f84da62ef56a4527c77efa3ee2a71de8 /packaging-tools/tests
parent2083a9e4f96f710946c9ca679b79f64570741df4 (diff)
pylint: Add miscellaneous checksv6.4.0-rc1-packaging
Add comment about disabled checks in pylint hook and enable all default pylint checks except for those. Address these miscellaneous pylint warnings: -C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck) -R1714: Consider merging these comparisons with "in" (consider-using-in) -R1722: Consider using sys.exit() (consider-using-sys-exit) -C0206: Consider iterating with .items() (consider-using-dict-items) -R1710: All return statements in a function should return an expression. (inconsistent-return-statements) -W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from) -W1510: Using subprocess.run without explicitly set `check` is not recommended. (subprocess-run-check) -W0102: Dangerous default value as argument (dangerous-default-value) -W1508: os.getenv default type is builtins.bool. Expected str or None. (invalid-envvar-default) -W0212: Access to a protected member of a client class (protected-access) -W0631: Using possibly undefined loop variable (undefined-loop-variable) -W1113: Keyword argument before variable positional arguments list in the definition of __init__ function (keyword-arg-before-vararg) -W0201: Attribute defined outside __init__ (attribute-defined-outside-init) -W0221: Number of parameters in overridden method differ (arguments-differ) -C0202: Class method should have 'cls' as first argument (bad-classmethod-argument) -W1505: Using deprecated method currentThread() (deprecated-method) -R1707: Disallow trailing comma tuple (trailing-comma-tuple) -W0603: Using the global statement (global-statement) -W0602: Using global for 'OUTPUT_STATES' but no assignment is done (global-variable-not-assigned) -C2801: Unnecessarily calls dunder method __contains__. Use in keyword. Change-Id: Ia1c6ff3f6c328a94b40a1c0f11c83151abc91423 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'packaging-tools/tests')
-rw-r--r--packaging-tools/tests/test_run_command.py10
-rw-r--r--packaging-tools/tests/testhelpers.py2
2 files changed, 6 insertions, 6 deletions
diff --git a/packaging-tools/tests/test_run_command.py b/packaging-tools/tests/test_run_command.py
index 57cbfee07..1adb18dc8 100644
--- a/packaging-tools/tests/test_run_command.py
+++ b/packaging-tools/tests/test_run_command.py
@@ -107,7 +107,7 @@ class TestRunCommand(unittest.TestCase):
self.assertEqual(expected_message_start, message_start)
expected_message_end = "9 printed line"
message_end = str(context_manager.exception).splitlines()[-1]
- self.assertTrue(message_end.__contains__(expected_message_end))
+ self.assertTrue(expected_message_end in message_end)
def test_different_exit_code_only_error_case_output(self):
self.assertEqual(
@@ -123,7 +123,7 @@ class TestRunCommand(unittest.TestCase):
)
def test_with_threadedwork(self):
- current_method_name = sys._getframe().f_code.co_name
+ current_method_name = sys._getframe().f_code.co_name # pylint: disable=W0212
test_work = ThreadedWork(f"{current_method_name} - run some command threaded")
task_string_list = []
task_string_list.append("--sleep 1 --print_lines 10")
@@ -136,7 +136,7 @@ class TestRunCommand(unittest.TestCase):
test_work.run()
def test_with_threadedwork_unexpected_exit_code(self):
- current_method_name = sys._getframe().f_code.co_name
+ current_method_name = sys._getframe().f_code.co_name # pylint: disable=W0212
test_work = ThreadedWork(f"{current_method_name} - run some command threaded")
# this exchange the current os._exit(-1) implementation only for this testing case
separator_line = f"{os.linesep}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>{os.linesep}"
@@ -153,7 +153,7 @@ class TestRunCommand(unittest.TestCase):
test_work.run()
def test_with_threadedwork_crash(self):
- current_method_name = sys._getframe().f_code.co_name
+ current_method_name = sys._getframe().f_code.co_name # pylint: disable=W0212
test_work = ThreadedWork(f"{current_method_name} - run some command threaded")
# this exchange the current os._exit(-1) implementation only for this testing case
separator_line = f"{os.linesep}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>{os.linesep}"
@@ -191,7 +191,7 @@ if __name__ == '__main__':
sys.__stderr__.flush()
crash()
if caller_arguments.exit_code:
- os._exit(caller_arguments.exit_code)
+ os._exit(caller_arguments.exit_code) # pylint: disable=W0212
if caller_arguments.testMethod:
# python test_run_command.py --testMethod test_crash_only_error_case_output
TestRunCommand(methodName=caller_arguments.testMethod).debug()
diff --git a/packaging-tools/tests/testhelpers.py b/packaging-tools/tests/testhelpers.py
index 91844b49d..ad7cfa696 100644
--- a/packaging-tools/tests/testhelpers.py
+++ b/packaging-tools/tests/testhelpers.py
@@ -67,7 +67,7 @@ def is_internal_file_server_reachable() -> bool:
try:
package_server = get_pkg_value("PACKAGE_STORAGE_SERVER")
ping = sh.which("ping")
- ret = subprocess.run(args=[ping, "-c", "1", package_server], timeout=5, stdout=PIPE, stderr=PIPE)
+ ret = subprocess.run(args=[ping, "-c", "1", package_server], timeout=5, stdout=PIPE, stderr=PIPE, check=False)
return ret.returncode == 0
except Exception:
pass