mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2025-12-20 04:30:09 +01:00
Reformat unittest_inspector.py using pylint and black
This commit is contained in:
parent
8e49826403
commit
f742b017b1
2 changed files with 31 additions and 15 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue