-
Notifications
You must be signed in to change notification settings - Fork 577
Description
I was going through tests and found that tests in test/type_check.py were not being run, but also, if I try and run them they fail, even if I fix the constructor parameters (see end of this issue for output).
I looked into this a bit and as far as I can tell (TypeCheck|SubjectType|PredicateType|ObjectType)Error
and check_(context|subject|predicate|object|statement|pattern)
is not being raised at all, I confirmed this by removing the functions and running tests and type checking - see changes: #1640
I also checked with grep after removing the exceptions and functions, and nothing matches:
$ egrep -ri -e '(TypeCheck|SubjectType|PredicateType|ObjectType)Error' -e 'check_(context|subject|predicate|object|statement|pattern)' rdflib/ examples/ test/ || echo NO MATCHES
NO MATCHES
I think it may be best to just remove all of these exceptions and functions, at the very least we should either fix or remove the tests test/type_check.py
.
Any input/feedback on this matter will be apreciated.
output
$ git log -1 --oneline
43d86224 (HEAD, upstream/master, gjhiggins/master, iwana-20211231T0217-flake8_strict) Merge pull request #1630 from aucampia/iwana-20211229T0112-fix_version
$ git diff
diff --git a/test/type_check.py b/test/type_check.py
index 19329a39..34a8d956 100644
--- a/test/type_check.py
+++ b/test/type_check.py
@@ -17,7 +17,7 @@ class TypeCheckCase(unittest.TestCase):
path = "store"
def setUp(self):
- self.store = Graph(backend=self.backend)
+ self.store = Graph(store=self.backend)
self.store.open(self.path)
def tearDown(self):
$ .venv/bin/python3 -m pytest test/type_check.py
============================================================================ test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/iwana/sw/d/github.com/iafork/rdflib, configfile: setup.cfg
plugins: subtests-0.5.0, cov-3.0.0
collected 3 items
test/type_check.py FFF [100%]
================================================================================= FAILURES ==================================================================================
_____________________________________________________________________ TypeCheckCase.testObjectTypeCheck _____________________________________________________________________
self = <test.type_check.TypeCheckCase testMethod=testObjectTypeCheck>
def testObjectTypeCheck(self):
> self.assertRaises(ObjectTypeError, self.store.add, (foo, foo, None))
test/type_check.py:33:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def add(self, triple: Tuple[Node, Node, Node]):
"""Add a triple with self as context"""
s, p, o = triple
assert isinstance(s, Node), "Subject %s must be an rdflib term" % (s,)
assert isinstance(p, Node), "Predicate %s must be an rdflib term" % (p,)
> assert isinstance(o, Node), "Object %s must be an rdflib term" % (o,)
E AssertionError: Object None must be an rdflib term
rdflib/graph.py:428: AssertionError
___________________________________________________________________ TypeCheckCase.testPredicateTypeCheck ____________________________________________________________________
self = <test.type_check.TypeCheckCase testMethod=testPredicateTypeCheck>
def testPredicateTypeCheck(self):
> self.assertRaises(PredicateTypeError, self.store.add, (foo, None, foo))
test/type_check.py:30:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def add(self, triple: Tuple[Node, Node, Node]):
"""Add a triple with self as context"""
s, p, o = triple
assert isinstance(s, Node), "Subject %s must be an rdflib term" % (s,)
> assert isinstance(p, Node), "Predicate %s must be an rdflib term" % (p,)
E AssertionError: Predicate None must be an rdflib term
rdflib/graph.py:427: AssertionError
____________________________________________________________________ TypeCheckCase.testSubjectTypeCheck _____________________________________________________________________
self = <test.type_check.TypeCheckCase testMethod=testSubjectTypeCheck>
def testSubjectTypeCheck(self):
> self.assertRaises(SubjectTypeError, self.store.add, (None, foo, foo))
test/type_check.py:27:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def add(self, triple: Tuple[Node, Node, Node]):
"""Add a triple with self as context"""
s, p, o = triple
> assert isinstance(s, Node), "Subject %s must be an rdflib term" % (s,)
E AssertionError: Subject None must be an rdflib term
rdflib/graph.py:426: AssertionError
========================================================================== short test summary info ==========================================================================
FAILED test/type_check.py::TypeCheckCase::testObjectTypeCheck - AssertionError: Object None must be an rdflib term
FAILED test/type_check.py::TypeCheckCase::testPredicateTypeCheck - AssertionError: Predicate None must be an rdflib term
FAILED test/type_check.py::TypeCheckCase::testSubjectTypeCheck - AssertionError: Subject None must be an rdflib term
============================================================================= 3 failed in 0.16s =============================================================================