62 if (library_path / path).is_file() |
62 if (library_path / path).is_file() |
63 ] |
63 ] |
64 |
64 |
65 import argparse |
65 import argparse |
66 |
66 |
67 def default_problem_message(message): |
|
68 if callable(message): |
|
69 import inspect |
|
70 spec = inspect.getfullargspec(message) |
|
71 args = {} |
|
72 assert not spec.varargs and not spec.varkw |
|
73 for argname in spec.args + spec.kwonlyargs: |
|
74 args[argname] = '<' + argname.replace('_', ' ') + '>' |
|
75 return message(**args) |
|
76 else: |
|
77 return message |
|
78 |
|
79 class ListTestSuiteAction(argparse.Action): |
67 class ListTestSuiteAction(argparse.Action): |
80 def __init__(self, option_strings, dest, nargs = None, **kwargs): |
68 def __init__(self, option_strings, dest, nargs = None, **kwargs): |
81 super().__init__(option_strings, dest, nargs = 0, **kwargs) |
69 super().__init__(option_strings, dest, nargs = 0, **kwargs) |
82 def __call__(self, *args, **kwargs): |
70 def __call__(self, *args, **kwargs): |
83 from testsuite import load_tests, all_warning_types |
71 import testsuite |
84 from sys import exit |
72 from sys import exit |
85 from re import sub |
73 from re import sub |
86 test_suite = load_tests() |
74 test_suite = testsuite.load_tests() |
87 for warning_type in sorted(all_warning_types(test_suite), key = lambda k: k.name): |
75 for warning_type in testsuite.all_problem_types(test_suite): |
88 print(str.format('{name}: {severity}: "{message}"', |
76 print(str.format('{name}: {severity}: "{message}"', |
89 name = warning_type.name, |
77 name = warning_type.name, |
90 severity = warning_type.severity, |
78 severity = warning_type.severity, |
91 message = default_problem_message(warning_type.message), |
79 message = warning_type.placeholder_message(), |
92 )) |
80 )) |
93 exit(0) |
81 exit(0) |
94 |
82 |
95 if __name__ == '__main__': |
83 if __name__ == '__main__': |
96 from sys import argv |
84 from sys import argv |