summaryrefslogtreecommitdiff
path: root/test/testutils.py
diff options
context:
space:
mode:
authorGunnar Aastrand Grimnes <gromgull@gmail.com>2016-11-21 16:37:05 +0100
committerGunnar Aastrand Grimnes <gromgull@gmail.com>2017-01-30 17:43:04 +0100
commitc267023ff0a1e89e511ea0b5d138ffcae059444b (patch)
treeb224f7620881804514c18151fa0c97e18b4875e6 /test/testutils.py
parent8bf3523652614337b8b2a12ff9820caeff74a2eb (diff)
downloadrdflib-c267023ff0a1e89e511ea0b5d138ffcae059444b.tar.gz
converted all tests
Diffstat (limited to 'test/testutils.py')
-rw-r--r--test/testutils.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/test/testutils.py b/test/testutils.py
index 6f97ea9d..6e044e6c 100644
--- a/test/testutils.py
+++ b/test/testutils.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import sys
import isodate
@@ -5,7 +6,7 @@ import datetime
from traceback import print_exc
from nose import SkipTest
-from earl import add_test, report
+from .earl import add_test, report
from rdflib import BNode, Graph, ConjunctiveGraph
@@ -22,7 +23,7 @@ def crapCompare(g1, g2):
o = _no_blank(t[2])
if not (s, t[1] ,o) in g2:
e = "(%s, %s, %s) is not in both graphs!"%(s, t[1], o)
- raise Exception, e
+ raise Exception(e)
def _no_blank(node):
if isinstance(node, BNode): return None
if isinstance(node, Graph):
@@ -34,16 +35,16 @@ def check_serialize_parse(fpath, infmt, testfmt, verbose=False):
_parse_or_report(verbose, g, fpath, format=infmt)
if verbose:
for t in g:
- print t
- print "========================================"
- print "Parsed OK!"
+ print(t)
+ print("========================================")
+ print("Parsed OK!")
s = g.serialize(format=testfmt)
if verbose:
- print s
+ print(s)
g2 = ConjunctiveGraph()
_parse_or_report(verbose, g2, data=s, format=testfmt)
if verbose:
- print g2.serialize()
+ print(g2.serialize())
crapCompare(g,g2)
@@ -52,9 +53,9 @@ def _parse_or_report(verbose, graph, *args, **kwargs):
graph.parse(*args, **kwargs)
except:
if verbose:
- print "========================================"
- print "Error in parsing serialization:"
- print args, kwargs
+ print("========================================")
+ print("Error in parsing serialization:")
+ print(args, kwargs)
raise
@@ -69,14 +70,14 @@ def nose_tst_earl_report(generator, earl_report_name=None):
for t in generator(args):
tests += 1
- print 'Running ', t[1].uri
+ print('Running ', t[1].uri)
try:
t[0](t[1])
add_test(t[1].uri, "passed")
success += 1
- except SkipTest, e:
+ except SkipTest as e:
add_test(t[1].uri, "untested", e.message)
- print "skipping %s - %s" % (t[1].uri, e.message)
+ print("skipping %s - %s" % (t[1].uri, e.message))
skip += 1
except KeyboardInterrupt:
@@ -88,11 +89,11 @@ def nose_tst_earl_report(generator, earl_report_name=None):
print_exc()
sys.stderr.write("%s\n" % t[1].uri)
- print "Ran %d tests, %d skipped, %d failed. "%(tests, skip, tests-skip-success)
+ print("Ran %d tests, %d skipped, %d failed. "%(tests, skip, tests-skip-success))
if earl_report_name:
now = isodate.datetime_isoformat(datetime.datetime.utcnow())
earl_report = 'test_reports/%s-%s.ttl' % (earl_report_name, now)
report.serialize(earl_report, format='n3')
report.serialize('test_reports/%s-latest.ttl'%earl_report_name, format='n3')
- print "Wrote EARL-report to '%s'" % earl_report
+ print("Wrote EARL-report to '%s'" % earl_report)