Skip to content

Commit

Permalink
converted all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gromgull authored and joernhees committed Jan 28, 2017
1 parent 83b6396 commit 7a2a6ea
Show file tree
Hide file tree
Showing 47 changed files with 363 additions and 362 deletions.
11 changes: 11 additions & 0 deletions rdflib/py3compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@
from six.moves.urllib.request import urlopen
from six.moves.urllib.request import build_opener

from six.moves.urllib.error import URLError
from six.moves.urllib.error import HTTPError

from six.moves.BaseHTTPServer import BaseHTTPRequestHandler
from six.moves.BaseHTTPServer import HTTPServer

if PY3:
import _thread as thread
from html.entities import name2codepoint
else:
import thread
from htmlentitydefs import name2codepoint


try:
from functools import wraps
Expand Down
130 changes: 65 additions & 65 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,89 +155,89 @@ def setup_python3():
join(tmp_src, 'run_tests.py'),
join(tmp_src, 'test', '__init__.py'),
join(tmp_src, 'test', 'earl.py'),
# join(tmp_src, 'test', 'manifest.py'),
join(tmp_src, 'test', 'manifest.py'),
join(tmp_src, 'test', 'rdfa', '__init__.py'),
# join(tmp_src, 'test', 'rdfa', 'run_w3c_rdfa_testsuite.py'),
# join(tmp_src, 'test', 'rdfa', 'test_non_xhtml.py'),
# join(tmp_src, 'test', 'store_performance.py'),
# join(tmp_src, 'test', 'test_aggregate_graphs.py'),
# join(tmp_src, 'test', 'test_bnode_ncname.py'),
# join(tmp_src, 'test', 'test_comparison.py'),
# join(tmp_src, 'test', 'test_conjunctive_graph.py'),
# join(tmp_src, 'test', 'test_conneg.py'),
# join(tmp_src, 'test', 'test_conventions.py'),
join(tmp_src, 'test', 'rdfa', 'run_w3c_rdfa_testsuite.py'),
join(tmp_src, 'test', 'rdfa', 'test_non_xhtml.py'),
join(tmp_src, 'test', 'store_performance.py'),
join(tmp_src, 'test', 'test_aggregate_graphs.py'),
join(tmp_src, 'test', 'test_bnode_ncname.py'),
join(tmp_src, 'test', 'test_comparison.py'),
join(tmp_src, 'test', 'test_conjunctive_graph.py'),
join(tmp_src, 'test', 'test_conneg.py'),
join(tmp_src, 'test', 'test_conventions.py'),
join(tmp_src, 'test', 'test_core_sparqlstore.py'),
# join(tmp_src, 'test', 'test_dataset.py'),
# join(tmp_src, 'test', 'test_datetime.py'),
# join(tmp_src, 'test', 'test_dawg.py'),
# join(tmp_src, 'test', 'test_diff.py'),
# join(tmp_src, 'test', 'test_empty_xml_base.py'),
join(tmp_src, 'test', 'test_dataset.py'),
join(tmp_src, 'test', 'test_datetime.py'),
join(tmp_src, 'test', 'test_dawg.py'),
join(tmp_src, 'test', 'test_diff.py'),
join(tmp_src, 'test', 'test_empty_xml_base.py'),
join(tmp_src, 'test', 'test_evaluate_bind.py'),
# join(tmp_src, 'test', 'test_events.py'),
# join(tmp_src, 'test', 'test_expressions.py'),
join(tmp_src, 'test', 'test_events.py'),
join(tmp_src, 'test', 'test_expressions.py'),
join(tmp_src, 'test', 'test_finalnewline.py'),
# join(tmp_src, 'test', 'test_graph.py'),
# join(tmp_src, 'test', 'test_graph_context.py'),
join(tmp_src, 'test', 'test_graph.py'),
join(tmp_src, 'test', 'test_graph_context.py'),
join(tmp_src, 'test', 'test_graph_formula.py'),
# join(tmp_src, 'test', 'test_graph_items.py'),
join(tmp_src, 'test', 'test_graph_items.py'),
join(tmp_src, 'test', 'test_initbindings.py'),
# join(tmp_src, 'test', 'test_iomemory.py'),
# join(tmp_src, 'test', 'test_issue084.py'),
join(tmp_src, 'test', 'test_iomemory.py'),
join(tmp_src, 'test', 'test_issue084.py'),
join(tmp_src, 'test', 'test_issue130.py'),
# join(tmp_src, 'test', 'test_issue154.py'),
join(tmp_src, 'test', 'test_issue154.py'),
join(tmp_src, 'test', 'test_issue160.py'),
# join(tmp_src, 'test', 'test_issue161.py'),
join(tmp_src, 'test', 'test_issue161.py'),
join(tmp_src, 'test', 'test_issue184.py'),
# join(tmp_src, 'test', 'test_issue190.py'),
join(tmp_src, 'test', 'test_issue190.py'),
join(tmp_src, 'test', 'test_issue200.py'),
join(tmp_src, 'test', 'test_issue209.py'),
join(tmp_src, 'test', 'test_issue247.py'),
# join(tmp_src, 'test', 'test_issue248.py'),
# join(tmp_src, 'test', 'test_issue363.py'),
# join(tmp_src, 'test', 'test_issue375.py'),
# join(tmp_src, 'test', 'test_issue379.py'),
join(tmp_src, 'test', 'test_issue248.py'),
join(tmp_src, 'test', 'test_issue363.py'),
join(tmp_src, 'test', 'test_issue375.py'),
join(tmp_src, 'test', 'test_issue379.py'),
join(tmp_src, 'test', 'test_issue_git_200.py'),
join(tmp_src, 'test', 'test_issue_git_336.py'),
# join(tmp_src, 'test', 'test_literal.py'),
# join(tmp_src, 'test', 'test_memory_store.py'),
# join(tmp_src, 'test', 'test_n3.py'),
# join(tmp_src, 'test', 'test_n3_suite.py'),
join(tmp_src, 'test', 'test_literal.py'),
join(tmp_src, 'test', 'test_memory_store.py'),
join(tmp_src, 'test', 'test_n3.py'),
join(tmp_src, 'test', 'test_n3_suite.py'),
join(tmp_src, 'test', 'test_namespace.py'),
# join(tmp_src, 'test', 'test_nodepickler.py'),
# join(tmp_src, 'test', 'test_nquads.py'),
# join(tmp_src, 'test', 'test_nquads_w3c.py'),
# join(tmp_src, 'test', 'test_nt_misc.py'),
join(tmp_src, 'test', 'test_nodepickler.py'),
join(tmp_src, 'test', 'test_nquads.py'),
join(tmp_src, 'test', 'test_nquads_w3c.py'),
join(tmp_src, 'test', 'test_nt_misc.py'),
join(tmp_src, 'test', 'test_nt_suite.py'),
# join(tmp_src, 'test', 'test_nt_w3c.py'),
# join(tmp_src, 'test', 'test_parser.py'),
# join(tmp_src, 'test', 'test_parser_helpers.py'),
# join(tmp_src, 'test', 'test_parser_structure.py'),
# join(tmp_src, 'test', 'test_path_div_future.py'),
# join(tmp_src, 'test', 'test_prefixTypes.py'),
# join(tmp_src, 'test', 'test_preflabel.py'),
# join(tmp_src, 'test', 'test_prettyxml.py'),
# join(tmp_src, 'test', 'test_rdf_lists.py'),
# join(tmp_src, 'test', 'test_rdfxml.py'),
# join(tmp_src, 'test', 'test_roundtrip.py'),
# join(tmp_src, 'test', 'test_rules.py'),
# join(tmp_src, 'test', 'test_seq.py'),
# join(tmp_src, 'test', 'test_serializexml.py'),
# join(tmp_src, 'test', 'test_slice.py'),
# join(tmp_src, 'test', 'test_sparql.py'),
# join(tmp_src, 'test', 'test_sparqlstore.py'),
# join(tmp_src, 'test', 'test_sparqlupdatestore.py'),
join(tmp_src, 'test', 'test_nt_w3c.py'),
join(tmp_src, 'test', 'test_parser.py'),
join(tmp_src, 'test', 'test_parser_helpers.py'),
join(tmp_src, 'test', 'test_parser_structure.py'),
join(tmp_src, 'test', 'test_path_div_future.py'),
join(tmp_src, 'test', 'test_prefixTypes.py'),
join(tmp_src, 'test', 'test_preflabel.py'),
join(tmp_src, 'test', 'test_prettyxml.py'),
join(tmp_src, 'test', 'test_rdf_lists.py'),
join(tmp_src, 'test', 'test_rdfxml.py'),
join(tmp_src, 'test', 'test_roundtrip.py'),
join(tmp_src, 'test', 'test_rules.py'),
join(tmp_src, 'test', 'test_seq.py'),
join(tmp_src, 'test', 'test_serializexml.py'),
join(tmp_src, 'test', 'test_slice.py'),
join(tmp_src, 'test', 'test_sparql.py'),
join(tmp_src, 'test', 'test_sparqlstore.py'),
join(tmp_src, 'test', 'test_sparqlupdatestore.py'),
join(tmp_src, 'test', 'test_swap_n3.py'),
# join(tmp_src, 'test', 'test_term.py'),
# join(tmp_src, 'test', 'test_trig.py'),
# join(tmp_src, 'test', 'test_trig_w3c.py'),
# join(tmp_src, 'test', 'test_trix_parse.py'),
# join(tmp_src, 'test', 'test_trix_serialize.py'),
# join(tmp_src, 'test', 'test_tsvresults.py'),
# join(tmp_src, 'test', 'test_turtle_serialize.py'),
# join(tmp_src, 'test', 'test_turtle_w3c.py'),
# join(tmp_src, 'test', 'test_util.py'),
join(tmp_src, 'test', 'test_term.py'),
join(tmp_src, 'test', 'test_trig.py'),
join(tmp_src, 'test', 'test_trig_w3c.py'),
join(tmp_src, 'test', 'test_trix_parse.py'),
join(tmp_src, 'test', 'test_trix_serialize.py'),
join(tmp_src, 'test', 'test_tsvresults.py'),
join(tmp_src, 'test', 'test_turtle_serialize.py'),
join(tmp_src, 'test', 'test_turtle_w3c.py'),
join(tmp_src, 'test', 'test_util.py'),
join(tmp_src, 'test', 'test_xmlliterals.py'),
# join(tmp_src, 'test', 'testutils.py'),
join(tmp_src, 'test', 'testutils.py'),
join(tmp_src, 'test', 'triple_store.py'),
join(tmp_src, 'test', 'type_check.py'),
]
Expand Down
7 changes: 5 additions & 2 deletions test/manifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import print_function

from collections import namedtuple
from nose.tools import nottest

from rdflib import Graph, RDF, RDFS, Namespace
from rdflib.py3compat import text_type

MF = Namespace('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#')
QT = Namespace('http://www.w3.org/2001/sw/DataAccess/tests/test-query#')
Expand All @@ -17,7 +20,7 @@ def read_manifest(f, base=None, legacy=False):

def _str(x):
if x is not None:
return unicode(x)
return text_type(x)
return None

g = Graph()
Expand Down Expand Up @@ -117,7 +120,7 @@ def _str(x):

else:
pass
print "I dont know DAWG Test Type %s" % _type
print("I dont know DAWG Test Type %s" % _type)
continue

yield _type, RDFTest(e, _str(name), _str(comment),
Expand Down
17 changes: 9 additions & 8 deletions test/rdfa/run_w3c_rdfa_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from operator import attrgetter
import re
import os
from urllib2 import urlopen
from urllib import url2pathname

from rdflib.py3compat import urlopen, url2pathname

from rdflib.graph import Graph
from rdflib.namespace import Namespace, RDF
Expand Down Expand Up @@ -149,13 +149,14 @@ def manual_run():
print(test.description)
try:
test()
print "PASSED"
except AssertionError, e:
print("PASSED")
except AssertionError as e:
failed += 1
print "****FAILED****", e;
except Exception, e:
errors += 1; print "****ERROR**** in %s" % test._source_urls, e
print "Ran %(count)s tests. Failed: %(failed)s. Errors: %(errors)s."%vars()
print("****FAILED****", e);
except Exception as e:
errors += 1
print("****ERROR**** in %s" % test._source_urls, e)
print("Ran %(count)s tests. Failed: %(failed)s. Errors: %(errors)s."%vars())


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion test/rdfa/test_non_xhtml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from unittest import TestCase
from urllib2 import URLError
from rdflib.py3compat import URLError

from rdflib.graph import ConjunctiveGraph

Expand Down
14 changes: 8 additions & 6 deletions test/store_performance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import unittest
import os
import gc
Expand Down Expand Up @@ -51,14 +53,14 @@ def tearDown(self):

def testTime(self):
number = 1
print self.store
print "input:",
print(self.store)
print("input:", end=' ')
for i in itertools.repeat(None, number):
self._testInput()
print "random:",
print("random:", end=' ')
for i in itertools.repeat(None, number):
self._testRandom()
print "."
print(".")

def _testRandom(self):
number = len(self.input)
Expand All @@ -75,7 +77,7 @@ def add_random():
for _i in it:
add_random()
t1 = time()
print "%.3g" % (t1 - t0),
print("%.3g" % (t1 - t0), end=' ')

def _testInput(self):
number = 1
Expand All @@ -90,7 +92,7 @@ def add_from_input():
for _i in it:
add_from_input()
t1 = time()
print "%.3g" % (t1 - t0),
print("%.3g" % (t1 - t0), end=' ')


class MemoryStoreTestCase(StoreTestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/test_aggregate_graphs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
from rdflib.namespace import Namespace, RDF, RDFS
from rdflib import plugin
from rdflib.py3compat import StringIO
from rdflib.term import URIRef
from rdflib.store import Store
from cStringIO import StringIO
from rdflib.graph import Graph
from rdflib.graph import ReadOnlyGraphAggregate
from rdflib.graph import ConjunctiveGraph
Expand Down
6 changes: 3 additions & 3 deletions test/test_bnode_ncname.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def uuid4():
# Have doubts about this. random.seed will just hash the string
random.seed('%s%s%s' % (preseed, os.getpid(), time.time()))
del preseed
t = long( time.time() * 1000.0 )
r = long( random.random()*100000000000000000L )
t = int( time.time() * 1000.0 )
r = int( random.random()*100000000000000000 )
try:
a = socket.gethostbyname( socket.gethostname() )
except:
# if we can't get a network address, just imagine one
a = random.random()*100000000000000000L
a = random.random()*100000000000000000
strdata = str(t)+' '+str(r)+' '+str(a)
data = md5(strdata.encode('ascii')).hexdigest()
yield data
Expand Down
Loading

0 comments on commit 7a2a6ea

Please sign in to comment.