Skip to content

Commit 9b3f790

Browse files
committed
added n3 test to check for internal float normalization
made as a separate commit to illustrate the old broken behavior priro to the fix in the next commit
1 parent 62c528d commit 9b3f790

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/test_n3.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,32 @@ def test_empty_prefix(self):
251251
g2
252252
), "Document with declared empty prefix must match default #"
253253

254+
def test_float_no_norm(self):
255+
import rdflib
256+
_ps = rdflib.NORMALIZE_LITERALS
257+
try:
258+
bads = []
259+
for norm_lit in (True, False):
260+
rdflib.NORMALIZE_LITERALS = norm_lit
261+
g1 = Graph()
262+
g1.parse(data=":a :b 1e10, 1e0 .", format="n3")
263+
strep = [str(o) for o in g1.objects()]
264+
if norm_lit:
265+
if '1e10' not in strep and '1e0' not in strep:
266+
pass
267+
else:
268+
bads.append(('NOT normalized when should have been', strep))
269+
else:
270+
if '1e10' in strep and '1e0' in strep:
271+
pass
272+
else:
273+
bads.append(('normalized when it should NOT have been', strep))
274+
275+
finally:
276+
rdflib.NORMALIZE_LITERALS = _ps
277+
278+
assert not bads, bads
279+
254280

255281
class TestRegularExpressions:
256282
def test_exponents(self):

0 commit comments

Comments
 (0)