Change test_issue_1141 to use data=file rather than BytesIO.
Added a further test in that file to check if the same thing continues to work with Ntriples parser too.
import unittest
-from io import BytesIO
from rdflib import Graph
from rdflib.plugins.stores.memory import Memory, SimpleMemory
@@ -17,25 +16,41 @@ class TestIssue1141(unittest.TestCase):
# with formula
graph = Graph()
self.assertTrue(graph.store.formula_aware)
- graph.parse(BytesIO(file), format=format)
+ graph.parse(data=file, format=format)
self.assertEqual(len(graph), 1)
# without
graph = Graph(store=AuditableStore(Memory()))
self.assertFalse(graph.store.formula_aware)
- graph.parse(BytesIO(file), format=format)
+ graph.parse(data=file, format=format)
self.assertEqual(len(graph), 1)
def test_issue_1141_2(self):
file = b"@prefix : <http://example.com/> . :s :p :o ."
+ # with formula
+ graph = Graph(store=Memory())
+ self.assertTrue(graph.store.formula_aware)
+ graph.parse(data=file, format="turtle")
+ self.assertEqual(len(graph), 1)
+
+ # without
+ graph = Graph(store=SimpleMemory())
+ self.assertFalse(graph.store.formula_aware)
+ graph.parse(data=file, format="turtle")
+ self.assertEqual(len(graph), 1)
+ def test_issue_1141_3(self):
+ file = b"<a:> <b:> <c:> ."
+ # with contexts
graph = Graph(store=Memory())
+ self.assertTrue(graph.store.context_aware)
self.assertTrue(graph.store.formula_aware)
- graph.parse(BytesIO(file), format="turtle")
+ graph.parse(data=file, format="nt")
self.assertEqual(len(graph), 1)
# without
graph = Graph(store=SimpleMemory())
+ self.assertFalse(graph.store.context_aware)
self.assertFalse(graph.store.formula_aware)
- graph.parse(BytesIO(file), format="turtle")
+ graph.parse(data=file, format="nt")
self.assertEqual(len(graph), 1)
