@@ -107,6 +107,45 @@ def test_add_rejects_in_memory_rdflib_graph(self):
107107 with self .assertRaises (TypeError ):
108108 self .env .add_no_imports (g )
109109
110+ def test_get_closure_with_in_memory_destination (self ):
111+ """Closure can be materialized into an in-memory rdflib.Graph."""
112+ base_path = self .test_dir / "base.ttl"
113+ imported_path = self .test_dir / "imported.ttl"
114+ imported_path .write_text (
115+ """
116+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
117+ @prefix ex: <http://example.com/imported#> .
118+ <http://example.com/imported> a owl:Ontology .
119+ ex:Thing a owl:Class .
120+ """ .strip ()
121+ + "\n " ,
122+ encoding = "utf-8" ,
123+ )
124+ base_path .write_text (
125+ """
126+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
127+ @prefix ex: <http://example.com/base#> .
128+ <http://example.com/base> a owl:Ontology ;
129+ owl:imports <http://example.com/imported> .
130+ ex:Root a owl:Class .
131+ """ .strip ()
132+ + "\n " ,
133+ encoding = "utf-8" ,
134+ )
135+
136+ self .env = OntoEnv (path = self .test_dir , recreate = True )
137+ # Load imported first so fetch_imports finds it locally.
138+ self .env .add (str (imported_path ), fetch_imports = False )
139+ base_name = self .env .add (str (base_path ))
140+
141+ destination = Graph ()
142+ closure_graph , closure_names = self .env .get_closure (base_name , destination_graph = destination )
143+
144+ self .assertIs (destination , closure_graph )
145+ self .assertGreater (len (closure_graph ), 0 )
146+ self .assertIn ("http://example.com/base" , closure_names )
147+ self .assertIn ("http://example.com/imported" , closure_names )
148+
110149 def test_get_graph (self ):
111150 """Test env.get_graph()."""
112151 self .env = OntoEnv (path = self .test_dir , recreate = True )
0 commit comments