Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

py3compat

  • Loading branch information...
commit 136e32ab0c59ca1642ea2b2478ec74afb86687a7 1 parent cac58d6
@gjhiggins gjhiggins authored
Showing with 79 additions and 79 deletions.
  1. +63 −63 test/graph_case.py
  2. +5 −5 test/test_postgresql.py
  3. +11 −11 tox.ini
View
126 test/graph_case.py
@@ -19,7 +19,7 @@ class GraphTestCase(unittest.TestCase):
hates = URIRef(u'hates')
pizza = URIRef(u'pizza')
cheese = URIRef(u'cheese')
-
+
def setUp(self):
self.graph = Graph(store=self.store_name)
self.graph.destroy(self.path)
@@ -29,7 +29,7 @@ def setUp(self):
else:
self.path = mkdtemp(prefix='test',dir='/tmp')
self.graph.open(self.path, create=self.create)
-
+
def tearDown(self):
self.graph.destroy(self.path)
try:
@@ -46,7 +46,7 @@ def tearDown(self):
os.unlink(self.path)
else:
os.remove(self.path)
-
+
def addStuff(self):
tarek = self.tarek
michel = self.michel
@@ -55,7 +55,7 @@ def addStuff(self):
hates = self.hates
pizza = self.pizza
cheese = self.cheese
-
+
self.graph.add((tarek, likes, pizza))
self.graph.add((tarek, likes, cheese))
self.graph.add((michel, likes, pizza))
@@ -64,7 +64,7 @@ def addStuff(self):
self.graph.add((bob, hates, pizza))
self.graph.add((bob, hates, michel)) # gasp!
self.graph.commit()
-
+
def removeStuff(self):
tarek = self.tarek
michel = self.michel
@@ -73,7 +73,7 @@ def removeStuff(self):
hates = self.hates
pizza = self.pizza
cheese = self.cheese
-
+
self.graph.remove((tarek, likes, pizza))
self.graph.remove((tarek, likes, cheese))
self.graph.remove((michel, likes, pizza))
@@ -81,14 +81,14 @@ def removeStuff(self):
self.graph.remove((bob, likes, cheese))
self.graph.remove((bob, hates, pizza))
self.graph.remove((bob, hates, michel)) # gasp!
-
+
def testAdd(self):
self.addStuff()
-
+
def testRemove(self):
self.addStuff()
self.removeStuff()
-
+
def testTriples(self):
tarek = self.tarek
michel = self.michel
@@ -100,49 +100,49 @@ def testTriples(self):
asserte = self.assertEquals
triples = self.graph.triples
Any = None
-
+
self.addStuff()
-
+
# unbound subjects
asserte(len(list(triples((Any, likes, pizza)))), 2)
asserte(len(list(triples((Any, hates, pizza)))), 1)
asserte(len(list(triples((Any, likes, cheese)))), 3)
asserte(len(list(triples((Any, hates, cheese)))), 0)
-
+
# unbound objects
asserte(len(list(triples((michel, likes, Any)))), 2)
asserte(len(list(triples((tarek, likes, Any)))), 2)
asserte(len(list(triples((bob, hates, Any)))), 2)
asserte(len(list(triples((bob, likes, Any)))), 1)
-
+
# unbound predicates
asserte(len(list(triples((michel, Any, cheese)))), 1)
asserte(len(list(triples((tarek, Any, cheese)))), 1)
asserte(len(list(triples((bob, Any, pizza)))), 1)
asserte(len(list(triples((bob, Any, michel)))), 1)
-
+
# unbound subject, objects
asserte(len(list(triples((Any, hates, Any)))), 2)
asserte(len(list(triples((Any, likes, Any)))), 5)
-
+
# unbound predicates, objects
asserte(len(list(triples((michel, Any, Any)))), 2)
asserte(len(list(triples((bob, Any, Any)))), 3)
asserte(len(list(triples((tarek, Any, Any)))), 2)
-
+
# unbound subjects, predicates
asserte(len(list(triples((Any, Any, pizza)))), 3)
asserte(len(list(triples((Any, Any, cheese)))), 3)
asserte(len(list(triples((Any, Any, michel)))), 1)
-
+
# all unbound
asserte(len(list(triples((Any, Any, Any)))), 7)
self.removeStuff()
asserte(len(list(triples((Any, Any, Any)))), 0)
-
+
def testStatementNode(self):
graph = self.graph
-
+
from rdflib.term import Statement
c = URIRef("http://example.org/foo#c")
r = URIRef("http://example.org/foo#r")
@@ -150,52 +150,52 @@ def testStatementNode(self):
graph.add((s, RDF.value, r))
self.assertEquals(r, graph.value(s, RDF.value))
self.assertEquals(s, graph.value(predicate=RDF.value, object=r))
-
+
def testGraphValue(self):
from rdflib.graph import GraphValue
-
+
graph = self.graph
-
+
alice = URIRef("alice")
bob = URIRef("bob")
pizza = URIRef("pizza")
cheese = URIRef("cheese")
-
+
g1 = Graph()
g1.add((alice, RDF.value, pizza))
g1.add((bob, RDF.value, cheese))
g1.add((bob, RDF.value, pizza))
-
+
g2 = Graph()
g2.add((bob, RDF.value, pizza))
g2.add((bob, RDF.value, cheese))
g2.add((alice, RDF.value, pizza))
-
+
gv1 = GraphValue(store=graph.store, graph=g1)
gv2 = GraphValue(store=graph.store, graph=g2)
graph.add((gv1, RDF.value, gv2))
v = graph.value(gv1)
- self.assertEquals(gv2, v)
+ self.assertEquals(gv2.identifier, v.identifier)
#print list(gv2)
#print gv2.identifier
graph.remove((gv1, RDF.value, gv2))
-
+
def testConnected(self):
graph = self.graph
self.addStuff()
self.assertEquals(True, graph.connected())
-
+
jeroen = URIRef("jeroen")
unconnected = URIRef("unconnected")
-
+
graph.add((jeroen,self.likes,unconnected))
-
+
self.assertEquals(False, graph.connected())
-
+
def testSub(self):
g1=Graph()
g2=Graph()
-
+
tarek = self.tarek
michel = self.michel
bob = self.bob
@@ -203,32 +203,32 @@ def testSub(self):
hates = self.hates
pizza = self.pizza
cheese = self.cheese
-
+
g1.add((tarek, likes, pizza))
g1.add((bob, likes, cheese))
-
+
g2.add((bob, likes, cheese))
-
+
g3=g1-g2
-
+
self.assertEquals(len(g3), 1)
self.assertEquals((tarek, likes, pizza) in g3, True)
self.assertEquals((tarek, likes, cheese) in g3, False)
-
+
self.assertEquals((bob, likes, cheese) in g3, False)
-
+
g1-=g2
-
+
self.assertEquals(len(g1), 1)
self.assertEquals((tarek, likes, pizza) in g1, True)
self.assertEquals((tarek, likes, cheese) in g1, False)
-
+
self.assertEquals((bob, likes, cheese) in g1, False)
-
+
def testGraphAdd(self):
g1=Graph()
g2=Graph()
-
+
tarek = self.tarek
michel = self.michel
bob = self.bob
@@ -236,31 +236,31 @@ def testGraphAdd(self):
hates = self.hates
pizza = self.pizza
cheese = self.cheese
-
+
g1.add((tarek, likes, pizza))
-
+
g2.add((bob, likes, cheese))
-
+
g3=g1+g2
-
+
self.assertEquals(len(g3), 2)
self.assertEquals((tarek, likes, pizza) in g3, True)
self.assertEquals((tarek, likes, cheese) in g3, False)
-
+
self.assertEquals((bob, likes, cheese) in g3, True)
-
+
g1+=g2
-
+
self.assertEquals(len(g1), 2)
self.assertEquals((tarek, likes, pizza) in g1, True)
self.assertEquals((tarek, likes, cheese) in g1, False)
-
+
self.assertEquals((bob, likes, cheese) in g1, True)
-
+
def testGraphIntersection(self):
g1=Graph()
g2=Graph()
-
+
tarek = self.tarek
michel = self.michel
bob = self.bob
@@ -268,32 +268,32 @@ def testGraphIntersection(self):
hates = self.hates
pizza = self.pizza
cheese = self.cheese
-
+
g1.add((tarek, likes, pizza))
g1.add((michel, likes, cheese))
-
+
g2.add((bob, likes, cheese))
g2.add((michel, likes, cheese))
-
+
g3=g1*g2
-
+
self.assertEquals(len(g3), 1)
self.assertEquals((tarek, likes, pizza) in g3, False)
self.assertEquals((tarek, likes, cheese) in g3, False)
-
+
self.assertEquals((bob, likes, cheese) in g3, False)
-
+
self.assertEquals((michel, likes, cheese) in g3, True)
-
+
g1*=g2
-
+
self.assertEquals(len(g1), 1)
-
+
self.assertEquals((tarek, likes, pizza) in g1, False)
self.assertEquals((tarek, likes, cheese) in g1, False)
-
+
self.assertEquals((bob, likes, cheese) in g1, False)
-
+
self.assertEquals((michel, likes, cheese) in g1, True)
View
10 test/test_postgresql.py
@@ -1,13 +1,13 @@
from nose import SkipTest
import unittest
-import test_graph
-import test_context
-from test_n3_2 import testN3Store
+import graph_case
+import context_case
+from n3_2_case import testN3Store
from rdflib.graph import Graph
configString="user=gjh,password=50uthf0rk,host=localhost,db=test"
-class PostgreSQLGraphTestCase(test_graph.GraphTestCase):
+class PostgreSQLGraphTestCase(graph_case.GraphTestCase):
store_name = "PostgreSQL"
storetest = True
path = configString
@@ -16,7 +16,7 @@ class PostgreSQLGraphTestCase(test_graph.GraphTestCase):
def testStatementNode(self):
raise SkipTest("RDF Statements not supported in AbstractSQLStore")
-class PostgreSQLContextTestCase(test_context.ContextTestCase):
+class PostgreSQLContextTestCase(context_case.ContextTestCase):
store_name = "PostgreSQL"
storetest = True
path = configString
View
22 tox.ini
@@ -1,39 +1,39 @@
[tox]
-envlist =
- py24,py25,py26,py27,cover#,py32,
+envlist =
+ py24,py25,py26,py27,cover,py32
[testenv]
-commands =
+commands =
{envpython} setup.py clean --all
{envpython} setup.py test
deps =
nose
- rdflib
- hg+http://code.google.com/p/rdfextras#egg=rdfextras
+ git+https://github.com/RDFLib/rdflib#egg=rdflib
+ git+https://github.com/RDFLib/rdfextras#egg=rdfextras
psycopg2
[testenv:py32]
basepython = python3.2
-commands =
+commands =
{envpython} setup.py clean --all
{envpython} setup.py build
nosetests -q --where=./build/src
deps =
nose
- rdflib
- hg+http://code.google.com/p/rdfextras#egg=rdfextras
+ git+https://github.com/RDFLib/rdflib#egg=rdflib
+ git+https://github.com/RDFLib/rdfextras#egg=rdfextras
psycopg2
[testenv:cover]
basepython = python2.7
-commands =
+commands =
nosetests --with-coverage --cover-html --cover-html-dir=./coverage \
--cover-package=rdflib_postgresql --cover-inclusive
deps =
nose
coverage
- rdflib
- hg+http://code.google.com/p/rdfextras#egg=rdfextras
+ git+https://github.com/RDFLib/rdflib#egg=rdflib
+ git+https://github.com/RDFLib/rdfextras#egg=rdfextras
psycopg2
# we separate coverage into its own testenv because a) "last run wins" wrt
Please sign in to comment.
Something went wrong with that request. Please try again.