File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -364,6 +364,11 @@ def namespace(self, prefix):
364364
365365 def namespaces (self ):
366366 """ """
367+ # This is here so that the function becomes an empty generator.
368+ # See https://stackoverflow.com/q/13243766 and
369+ # https://www.python.org/dev/peps/pep-0255/#why-a-new-keyword-for-yield-why-not-a-builtin-function-instead
370+ if False :
371+ yield None # type: ignore[unreachable]
367372
368373 # Optional Transactional methods
369374
Original file line number Diff line number Diff line change 1+ import unittest
2+ from rdflib import Graph
3+ from rdflib .store import Store
4+ from rdflib .namespace import NamespaceManager
5+
6+
7+ class TestAbstractStore (unittest .TestCase ):
8+ def test_namespaces (self ):
9+ """
10+ This tests that Store.namespaces is an empty generator.
11+ """
12+ store = Store ()
13+ self .assertEqual (list (store .namespaces ()), [])
14+
15+ def test_namespaces_via_manager (self ):
16+ """
17+ This tests that NamespaceManager.namespaces works correctly with an
18+ abstract Store.
19+ """
20+ namespace_manager = NamespaceManager (Graph (store = Store ()))
21+ self .assertEqual (list (namespace_manager .namespaces ()), [])
22+
23+
24+ if __name__ == "__main__" :
25+ unittest .main ()
You can’t perform that action at this time.
0 commit comments