[pypy-svn] r33658 - in pypy/dist/pypy/lib/pyontology: . test
ale at codespeak.net
ale at codespeak.net
Tue Oct 24 16:57:54 CEST 2006
Author: ale
Date: Tue Oct 24 16:57:53 2006
New Revision: 33658
Modified:
pypy/dist/pypy/lib/pyontology/constraint_classes.py
pypy/dist/pypy/lib/pyontology/pyontology.py
pypy/dist/pypy/lib/pyontology/test/test_ontology.py
Log:
ups, bugfix and a test
Modified: pypy/dist/pypy/lib/pyontology/constraint_classes.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/constraint_classes.py (original)
+++ pypy/dist/pypy/lib/pyontology/constraint_classes.py Tue Oct 24 16:57:53 2006
@@ -193,7 +193,7 @@
domaindom = domains[self.object]
for cls,val in propdom.getValues():
if cls not in domaindom:
- raise ConsistencyFailure("Value %r of property %r not in domain %r"%(pval, self.variable, self.object))
+ raise ConsistencyFailure("Value %r of property %r not in domain %r : %r"%(cls, self.variable, self.object, domaindom.getValues()))
class SubPropertyConstraint(SubClassConstraint):
Modified: pypy/dist/pypy/lib/pyontology/pyontology.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/pyontology.py (original)
+++ pypy/dist/pypy/lib/pyontology/pyontology.py Tue Oct 24 16:57:53 2006
@@ -845,6 +845,7 @@
svar = self.make_var(ClassDomain, s)
self.variables[svar].bases.append(avar)
self.variables[svar].bases.extend(self.variables[avar].bases)
+ self.constraints.append(SubClassConstraint(svar, avar))
def equivalentClass(self, s, var):
self.subClassOf(s, var)
Modified: pypy/dist/pypy/lib/pyontology/test/test_ontology.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/test/test_ontology.py (original)
+++ pypy/dist/pypy/lib/pyontology/test/test_ontology.py Tue Oct 24 16:57:53 2006
@@ -73,6 +73,23 @@
O.subClassOf(c, a)
O.consistency()
+def test_subClassof2():
+ O = Ontology()
+ a = URIRef(u'A')
+ b = URIRef(u'B')
+ c = URIRef(u'C')
+ d = URIRef(u'D')
+ O.subClassOf(b, a)
+ O.subClassOf(c, b)
+ obj = URIRef(namespaces['owl']+'#Class')
+ O.type(a,obj)
+ O.type(d,c)
+ O.consistency()
+ d_indi = O.mangle_name(d)
+ assert Individual(d_indi, d) in O.variables[O.mangle_name(a)].getValues()
+ O.subClassOf(c, a)
+ O.consistency()
+
def test_addvalue():
O = Ontology()
a = O.make_var(Property, URIRef('a'))
More information about the Pypy-commit
mailing list