Skip to content

Commit 8f95718

Browse files
committed
test for mutate_simplify_pattern making sure we keep Literals
1 parent 3613b7f commit 8f95718

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/test_gp_learner_offline.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import random
99

1010
import rdflib
11+
from rdflib import Literal
1112
from rdflib import URIRef
1213
from rdflib import Variable
1314
from scipy.stats import binom
@@ -219,6 +220,20 @@ def test_simplify_pattern():
219220
res = mutate_simplify_pattern(gp2)
220221
assert res == gp, 'not simplified:\n%s\nto\n%s' % (gp2, res)
221222

223+
# make sure that we keep literals
224+
gp = GraphPattern([
225+
(SOURCE_VAR, Variable('p'), Literal('foo')),
226+
(SOURCE_VAR, wikilink, Literal('bar')),
227+
(SOURCE_VAR, wikilink, TARGET_VAR),
228+
(TARGET_VAR, Variable('q'), Literal('bla')),
229+
(SOURCE_VAR, wikilink, Literal('blu')),
230+
(SOURCE_VAR, Variable('r'), Literal('foobar')),
231+
(TARGET_VAR, Variable('r'), Literal('foobar')),
232+
233+
])
234+
res = mutate_simplify_pattern(gp)
235+
assert res == gp, 'was simplified (bad):\n%s\nto\n%s' % (gp, res)
236+
222237

223238
def test_remaining_gain_sample_gtps():
224239
n = len(ground_truth_pairs)

0 commit comments

Comments
 (0)