unittest.py

changeset 127
97de6058109e
parent 126
16dae12ac0f0
child 145
fde18c4d6784
--- a/unittest.py	Fri Sep 18 20:46:26 2020 +0300
+++ b/unittest.py	Fri Sep 18 20:59:59 2020 +0300
@@ -102,6 +102,10 @@
     return problem_tuple[0] + ':' + str(problem_tuple[1])
 
 def run_unit_test_suite():
+    from argparse import ArgumentParser
+    parser = ArgumentParser()
+    parser.add_argument('-d', '--debug', action = 'store_true')
+    args = parser.parse_args()
     config = load_config()
     test_suite = load_tests()
     num_tested = 0
@@ -117,11 +121,14 @@
                 test_suite = test_suite
             )
         except Exception as error:
-            print(str.format(
-                'Error running {test_name}: {error}',
-                test_name = unit_test_path.name,
-                error = str(error),
-            ))
+            if args.debug:
+                raise
+            else:
+                print(str.format(
+                    'Error running {test_name}: {error}',
+                    test_name = unit_test_path.name,
+                    error = str(error),
+                ))
         else:
             print(str.format(
                 '{name}: {verdict}',

mercurial