forked from RDFLib/rdflib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_issue1141.py
57 lines (47 loc) · 1.91 KB
/
test_issue1141.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import unittest
from rdflib import Graph
from rdflib.plugins.stores.memory import Memory, SimpleMemory
from rdflib.plugins.stores.auditable import AuditableStore
class TestIssue1141(unittest.TestCase):
"""
Tests is Turtle and TriG parsing works with a store with or without formula support
"""
def test_issue_1141_1(self):
file = b"@prefix : <http://example.com/> . :s :p :o ."
for format in ("turtle", "trig"):
# with formula
graph = Graph()
self.assertTrue(graph.store.formula_aware)
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(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(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(data=file, format="nt")
self.assertEqual(len(graph), 1)