]> arthur.barton.de Git - bup.git/blobdiff - wvtest.py
wvtest: precompile _code() regex
[bup.git] / wvtest.py
index ef03381bd0328bd8ae23476152b9bcfaf1e01b0f..561cc8794ba8e93fc43be65fbd5a50ba53922bb0 100755 (executable)
--- a/wvtest.py
+++ b/wvtest.py
@@ -71,11 +71,11 @@ if __name__ != '__main__':   # we're imported as a module
             _result(msg, tb, 'FAILED')
         return cond
 
-
+    _code_rx = re.compile(r'^\w+\((.*)\)(\s*#.*)?$')
     def _code():
         (filename, line, func, text) = traceback.extract_stack()[-3]
-        text = re.sub(r'^\w+\((.*)\)(\s*#.*)?$', r'\1', text);
-        return text
+        return _code_rx.sub(r'\1', text)
+
 
 
     def WVMSG(message):
@@ -122,7 +122,7 @@ if __name__ != '__main__':   # we're imported as a module
         '''
         try:
             func(*args, **kwargs)
-        except etype, e:
+        except etype as e:
             return _check(True, 'EXCEPT(%s)' % _code())
         except:
             _check(False, 'EXCEPT(%s)' % _code())
@@ -186,7 +186,7 @@ def _runtest(fname, f):
     sys.stdout.flush()
     try:
         _run_in_chdir(os.path.split(mod.__file__)[0], f)
-    except Exception, e:
+    except Exception as e:
         print
         print traceback.format_exc()
         tb = sys.exc_info()[2]
@@ -201,7 +201,7 @@ def _run_registered_tests():
         print
 
 
-def wvtest_main(extra_testfiles=[]):
+def wvtest_main(extra_testfiles=tuple()):
     import wvtest as _wvtestmod
     _run_registered_tests()
     for modname in extra_testfiles: