summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regtest/Config.py4
-rw-r--r--regtest/TestReferences.py8
-rw-r--r--regtest/TestRun.py32
-rw-r--r--regtest/Timer.py8
-rw-r--r--regtest/backends/__init__.py12
-rw-r--r--regtest/commands/__init__.py6
-rw-r--r--regtest/commands/create-refs.py2
-rw-r--r--regtest/commands/run-tests.py2
-rw-r--r--regtest/main.py2
9 files changed, 38 insertions, 38 deletions
diff --git a/regtest/Config.py b/regtest/Config.py
index 197edcea..ff03e3ca 100644
--- a/regtest/Config.py
+++ b/regtest/Config.py
@@ -27,6 +27,6 @@ class Config:
if __name__ == '__main__':
c = Config({'foo' : 25})
- print c.foo
+ print(c.foo)
cc = Config()
- print cc.foo
+ print(cc.foo)
diff --git a/regtest/TestReferences.py b/regtest/TestReferences.py
index 042b0d43..cfd48532 100644
--- a/regtest/TestReferences.py
+++ b/regtest/TestReferences.py
@@ -32,7 +32,7 @@ class TestReferences:
try:
os.makedirs(self._refsdir)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
except:
@@ -46,7 +46,7 @@ class TestReferences:
refs_path = os.path.join(self._refsdir, filename)
try:
os.makedirs(refs_path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
except:
@@ -60,9 +60,9 @@ class TestReferences:
for backend in backends:
if not self.config.force and backend.has_md5(refs_path):
- print "Checksum file found, skipping '%s' for %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs)
+ print("Checksum file found, skipping '%s' for %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs))
continue
- print "Creating refs for '%s' using %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs)
+ print("Creating refs for '%s' using %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs))
if backend.create_refs(doc_path, refs_path):
backend.create_checksums(refs_path, self.config.checksums_only)
diff --git a/regtest/TestRun.py b/regtest/TestRun.py
index ba74b1a6..f03840bb 100644
--- a/regtest/TestRun.py
+++ b/regtest/TestRun.py
@@ -42,7 +42,7 @@ class TestRun:
try:
os.makedirs(self._outdir);
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
except:
@@ -54,7 +54,7 @@ class TestRun:
ref_is_crashed = backend.is_crashed(refs_path)
ref_is_failed = backend.is_failed(refs_path)
if not ref_has_md5 and not ref_is_crashed and not ref_is_failed:
- print "Reference files not found, skipping '%s' for %s backend" % (doc_path, backend.get_name())
+ print("Reference files not found, skipping '%s' for %s backend" % (doc_path, backend.get_name()))
return
self._n_tests += 1
@@ -68,40 +68,40 @@ class TestRun:
if ref_has_md5 and test_has_md5:
if backend.compare_checksums(refs_path, test_path, not self.config.keep_results, self.config.create_diffs):
# FIXME: remove dir if it's empty?
- print "PASS"
+ print("PASS")
self._n_passed += 1
else:
- print "FAIL"
+ print("FAIL")
self._failed.append("%s (%s)" % (doc_path, backend.get_name()))
return
elif test_has_md5:
if ref_is_crashed:
- print "DOES NOT CRASH"
+ print("DOES NOT CRASH")
elif ref_is_failed:
- print "DOES NOT FAIL"
+ print("DOES NOT FAIL")
return
test_is_crashed = backend.is_crashed(test_path)
if ref_is_crashed and test_is_crashed:
- print "PASS (Expected crash)"
+ print("PASS (Expected crash)")
self._n_passed += 1
return
test_is_failed = backend.is_failed(test_path)
if ref_is_failed and test_is_failed:
# FIXME: compare status errors
- print "PASS (Expected fail with status error %d)" % (test_is_failed)
+ print("PASS (Expected fail with status error %d)" % (test_is_failed))
self._n_passed += 1
return
if test_is_crashed:
- print "CRASH"
+ print("CRASH")
self._crashed.append("%s (%s)" % (doc_path, backend.get_name()))
return
if test_is_failed:
- print "FAIL (status error %d)" % (test_is_failed)
+ print("FAIL (status error %d)" % (test_is_failed))
self._failed_status_error("%s (%s)" % (doc_path, backend.get_name()))
return
@@ -113,7 +113,7 @@ class TestRun:
out_path = os.path.join(self._outdir, filename)
try:
os.makedirs(out_path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
except:
@@ -122,7 +122,7 @@ class TestRun:
refs_path = os.path.join(self._refsdir, filename)
if not os.path.isdir(refs_path):
- print "Reference dir not found for %s, skipping (%d/%d)" % (doc_path, n_doc, total_docs)
+ print("Reference dir not found for %s, skipping (%d/%d)" % (doc_path, n_doc, total_docs))
return
if self.config.backends:
@@ -142,16 +142,16 @@ class TestRun:
def summary(self):
if not self._n_tests:
- print "No tests run"
+ print("No tests run")
return
- print "Total %d tests" % (self._n_tests)
- print "%d tests passed (%.2f%%)" % (self._n_passed, (self._n_passed * 100.) / self._n_tests)
+ print("Total %d tests" % (self._n_tests))
+ print("%d tests passed (%.2f%%)" % (self._n_passed, (self._n_passed * 100.) / self._n_tests))
def report_tests(test_list, test_type):
n_tests = len(test_list)
if not n_tests:
return
- print "%d tests %s (%.2f%%): %s" % (n_tests, test_type, (n_tests * 100.) / self._n_tests, ", ".join(test_list))
+ print("%d tests %s (%.2f%%): %s" % (n_tests, test_type, (n_tests * 100.) / self._n_tests, ", ".join(test_list)))
report_tests(self._failed, "failed")
report_tests(self._crashed, "crashed")
report_tests(self._failed_status_error, "failed to run")
diff --git a/regtest/Timer.py b/regtest/Timer.py
index 102af965..e86f8c52 100644
--- a/regtest/Timer.py
+++ b/regtest/Timer.py
@@ -61,13 +61,13 @@ if __name__ == '__main__':
t = Timer()
sleep(5)
- print "Elapsed: %s" % (t.elapsed_str())
+ print("Elapsed: %s" % (t.elapsed_str()))
sleep(1)
- print "Elapsed: %s" % (t.elapsed_str())
+ print("Elapsed: %s" % (t.elapsed_str()))
t.start()
sleep(2)
t.stop()
- print "Elapsed: %s" % (t.elapsed_str())
+ print("Elapsed: %s" % (t.elapsed_str()))
sleep(2)
- print "Elapsed: %s" % (t.elapsed_str())
+ print("Elapsed: %s" % (t.elapsed_str()))
diff --git a/regtest/backends/__init__.py b/regtest/backends/__init__.py
index e730eaa7..ed728ff9 100644
--- a/regtest/backends/__init__.py
+++ b/regtest/backends/__init__.py
@@ -46,7 +46,7 @@ class Backend:
if not entry.startswith(self._name) or entry.endswith('.md5'):
continue
ref_path = os.path.join(refs_path, entry)
- f = open(ref_path, 'r')
+ f = open(ref_path, 'rb')
md5_file.write("%s %s\n" % (md5(f.read()).hexdigest(), ref_path))
f.close()
if delete_refs:
@@ -66,21 +66,21 @@ class Backend:
basename = os.path.basename(ref_path)
if not basename in tests:
retval = False
- print "%s found in md5 ref file but missing in output dir %s" % (basename, out_path)
+ print("%s found in md5 ref file but missing in output dir %s" % (basename, out_path))
continue
result_path = os.path.join(out_path, basename)
- f = open(result_path, 'r')
+ f = open(result_path, 'rb')
matched = md5sum == md5(f.read()).hexdigest()
f.close()
if matched:
if remove_results:
os.remove(result_path)
else:
- print "Differences found in %s" % (basename)
+ print("Differences found in %s" % (basename))
if create_diffs:
if not os.path.exists(ref_path):
- print "Reference file %s not found, skipping diff for %s" % (ref_path, result_path)
+ print("Reference file %s not found, skipping diff for %s" % (ref_path, result_path))
else:
try:
self._create_diff(ref_path, result_path)
@@ -115,7 +115,7 @@ class Backend:
def __create_stderr_file(self, stderr, out_path):
if not stderr:
return
- stderr_file = open(out_path + '.stderr', 'w')
+ stderr_file = open(out_path + '.stderr', 'wb')
stderr_file.write(stderr)
stderr_file.close()
diff --git a/regtest/commands/__init__.py b/regtest/commands/__init__.py
index 93cec6c5..86f58fd7 100644
--- a/regtest/commands/__init__.py
+++ b/regtest/commands/__init__.py
@@ -83,11 +83,11 @@ def print_help():
except ImportError:
pass
- print "Commands are:"
+ print("Commands are:")
commands = [(x.name, x.description) for x in _commands.values()]
commands.sort()
for name, description in commands:
- print " %-15s %s" % (name, description)
+ print(" %-15s %s" % (name, description))
print
- print "For more information run 'poppler-regtest --help-command <command>'"
+ print("For more information run 'poppler-regtest --help-command <command>'")
diff --git a/regtest/commands/create-refs.py b/regtest/commands/create-refs.py
index 081a7e81..b055703d 100644
--- a/regtest/commands/create-refs.py
+++ b/regtest/commands/create-refs.py
@@ -60,6 +60,6 @@ class CreateRefs(Command):
refs.create_refs()
else:
refs.create_refs_for_file(os.path.basename(doc))
- print "Refs created in %s" % (t.elapsed_str())
+ print("Refs created in %s" % (t.elapsed_str()))
register_command('create-refs', CreateRefs)
diff --git a/regtest/commands/run-tests.py b/regtest/commands/run-tests.py
index 2c564c7d..c1a8b6f8 100644
--- a/regtest/commands/run-tests.py
+++ b/regtest/commands/run-tests.py
@@ -64,6 +64,6 @@ class RunTests(Command):
else:
tests.run_test(os.path.basename(doc))
tests.summary()
- print "Tests run in %s" % (t.elapsed_str())
+ print("Tests run in %s" % (t.elapsed_str()))
register_command('run-tests', RunTests)
diff --git a/regtest/main.py b/regtest/main.py
index 4c8a3905..a46a64c2 100644
--- a/regtest/main.py
+++ b/regtest/main.py
@@ -71,7 +71,7 @@ def main(args):
sys.stderr.write("Unknown command: %s\n" % (args[0]))
commands.print_help()
sys.exit(1)
- except backends.UnknownBackendError, e:
+ except backends.UnknownBackendError as e:
sys.stderr.write(str(e) + "\n")
sys.stdout.write("Backends are: %s\n" % (", ".join([backend.get_name() for backend in backends.get_all_backends()])))
sys.exit(1)