From f742b017b1e6aa5836551ec7c1e3ea59064c2706 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 5 Feb 2024 15:24:33 -0600 Subject: [PATCH] Reformat unittest_inspector.py using pylint and black --- .ci/fail_skipped_tests.py | 36 +++++++++++++++++++++++++----------- tests/unittest_inspector.py | 10 ++++++---- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.ci/fail_skipped_tests.py b/.ci/fail_skipped_tests.py index 6349921..868fd06 100755 --- a/.ci/fail_skipped_tests.py +++ b/.ci/fail_skipped_tests.py @@ -3,23 +3,37 @@ from lxml import etree import sys + def format_title(title): """Put title in a box""" box = { - 'tl': '╔', 'tr': '╗', 'bl': '╚', 'br': '╝', 'h': '═', 'v': '║', + "tl": "╔", + "tr": "╗", + "bl": "╚", + "br": "╝", + "h": "═", + "v": "║", } - hline = box['h'] * (len(title) + 2) + hline = box["h"] * (len(title) + 2) + + return "\n".join( + [ + f"{box['tl']}{hline}{box['tr']}", + f"{box['v']} {title} {box['v']}", + f"{box['bl']}{hline}{box['br']}", + ] + ) - return '\n'.join([ - f"{box['tl']}{hline}{box['tr']}", - f"{box['v']} {title} {box['v']}", - f"{box['bl']}{hline}{box['br']}", - ]) tree = etree.parse(sys.argv[1]) -for suite in tree.xpath('/testsuites/testsuite'): - skipped = suite.get('skipped') +for suite in tree.xpath("/testsuites/testsuite"): + skipped = suite.get("skipped") if int(skipped) != 0: - print(format_title('Tests were skipped when they should not have been. All the tests must be run in the CI'), - end='\n\n', flush=True) + print( + format_title( + "Tests were skipped when they should not have been. All the tests must be run in the CI" + ), + end="\n\n", + flush=True, + ) sys.exit(1) diff --git a/tests/unittest_inspector.py b/tests/unittest_inspector.py index 0d5d3a6..db595a4 100644 --- a/tests/unittest_inspector.py +++ b/tests/unittest_inspector.py @@ -22,23 +22,25 @@ import inspect import os import unittest + def list_tests(module): tests = [] for name, obj in inspect.getmembers(module): if inspect.isclass(obj) and issubclass(obj, unittest.TestCase): cases = unittest.defaultTestLoader.getTestCaseNames(obj) - tests += [ (obj, '{}.{}'.format(name, t)) for t in cases ] + tests += [(obj, "{}.{}".format(name, t)) for t in cases] return tests -if __name__ == '__main__': +if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('unittest_source', type=argparse.FileType('r')) + parser.add_argument("unittest_source", type=argparse.FileType("r")) args = parser.parse_args() source_path = args.unittest_source.name spec = importlib.util.spec_from_file_location( - os.path.basename(source_path), source_path) + os.path.basename(source_path), source_path + ) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module)