]> arthur.barton.de Git - bup.git/commitdiff
wvtest.py: switch to print_function
authorRob Browning <rlb@defaultvalue.org>
Thu, 18 Jan 2018 01:57:47 +0000 (19:57 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sun, 13 Oct 2019 16:50:32 +0000 (11:50 -0500)
Python 3 requires it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
wvtest.py

index 8b5ab647e47e270caccbd67c31789211b32f6ce8..4cf83d9399db27ff4e6ea754985a66b233a06816 100755 (executable)
--- a/wvtest.py
+++ b/wvtest.py
@@ -13,7 +13,7 @@ exec "$bup_python" "$0" ${1+"$@"}
 #       You can get wvtest from: http://github.com/apenwarr/wvtest
 #
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 import atexit
 import inspect
 import os
@@ -63,8 +63,8 @@ if __name__ != '__main__':   # we're imported as a module
         filename = os.path.basename(filename)
         msg = re.sub(r'\s+', ' ', str(msg))
         sys.stderr.flush()
-        print '! %-70s %s' % ('%s:%-4d %s' % (filename, line, msg),
-                              code)
+        print('! %-70s %s' % ('%s:%-4d %s' % (filename, line, msg),
+                              code))
         sys.stdout.flush()
 
 
@@ -173,7 +173,7 @@ if __name__ != '__main__':   # we're imported as a module
     def _check_unfinished():
         if _registered:
             for func in _registered:
-                print 'WARNING: not run: %r' % (func,)
+                print('WARNING: not run: %r' % (func,))
             WVFAIL('wvtest_main() not called')
         if _fails:
             sys.exit(1)
@@ -218,14 +218,14 @@ else:
 def _runtest(fname, f):
     mod = inspect.getmodule(f)
     relpath = _relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py')
-    print
-    print 'Testing "%s" in %s:' % (fname, relpath)
+    print()
+    print('Testing "%s" in %s:' % (fname, relpath))
     sys.stdout.flush()
     try:
         _run_in_chdir(os.path.split(mod.__file__)[0], f)
     except Exception as e:
-        print
-        print traceback.format_exc()
+        print()
+        print(traceback.format_exc())
         tb = sys.exc_info()[2]
         wvtest._result(e, traceback.extract_tb(tb)[1], 'EXCEPTION')
 
@@ -235,7 +235,7 @@ def _run_registered_tests():
     while _wvtestmod._registered:
         t = _wvtestmod._registered.pop(0)
         _runtest(t.func_name, t)
-        print
+        print()
 
 
 def wvtest_main(extra_testfiles=tuple()):
@@ -243,20 +243,20 @@ def wvtest_main(extra_testfiles=tuple()):
     _run_registered_tests()
     for modname in extra_testfiles:
         if not os.path.exists(modname):
-            print 'Skipping: %s' % modname
+            print('Skipping: %s' % modname)
             continue
         if modname.endswith('.py'):
             modname = modname[:-3]
-        print 'Importing: %s' % modname
+        print('Importing: %s' % modname)
         path, mod = os.path.split(os.path.abspath(modname))
         nicename = modname.replace(os.path.sep, '.')
         while nicename.startswith('.'):
             nicename = modname[1:]
         _run_in_chdir(path, __import__, nicename, None, None, [])
         _run_registered_tests()
-    print
-    print 'WvTest: %d tests, %d failures.' % (_wvtestmod._tests,
-                                              _wvtestmod._fails)
+    print()
+    print('WvTest: %d tests, %d failures.' % (_wvtestmod._tests,
+                                              _wvtestmod._fails))
 
 
 if __name__ == '__main__':