Skip to content

Commit 01d179d

Browse files
committed
Fix regression with fractionals and adjust tests
1 parent a769ef8 commit 01d179d

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/pyld/jsonld.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4003,7 +4003,7 @@ def _object_to_rdf(self, item, issuer, triples, options):
40034003
)
40044004
elif _is_integer(value):
40054005
return Literal(
4006-
str(value),
4006+
str(int(value)),
40074007
datatype=datatype if datatype else XSD.integer,
40084008
normalize=False,
40094009
)

tests/test_jsonld.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def test_large_integer_to_rdf_double_conversion_processing_mode(self):
944944
nquads = jsonld.to_rdf(input, options={'format': 'application/n-quads'})
945945
assert nquads == (
946946
'<http://example.com/s> <http://example.com/p> '
947-
'"1.0E21"^^<http://www.w3.org/2001/XMLSchema#double> .\n'
947+
'"1.0E21"^^<http://www.w3.org/2001/XMLSchema#double> .\n\n'
948948
)
949949

950950
nquads = jsonld.to_rdf(
@@ -957,7 +957,7 @@ def test_large_integer_to_rdf_double_conversion_processing_mode(self):
957957
assert nquads == (
958958
'<http://example.com/s> <http://example.com/p> '
959959
'"1000000000000000000000"'
960-
'^^<http://www.w3.org/2001/XMLSchema#integer> .\n'
960+
'^^<http://www.w3.org/2001/XMLSchema#integer> .\n\n'
961961
)
962962

963963
def test_compound_literal_direction_without_language(self):
@@ -1081,7 +1081,7 @@ def test_fractional(self):
10811081
"""
10821082
input = { "ex:value": 42.0 }
10831083

1084-
expected = '_:b0 <ex:value> "42"^^<http://www.w3.org/2001/XMLSchema#integer> .\n'
1084+
expected = '_:b0 <ex:value> "42"^^<http://www.w3.org/2001/XMLSchema#integer> .\n\n'
10851085

10861086
nquads = jsonld.to_rdf(input, options={'format': 'application/n-quads'})
10871087
assert nquads == expected
@@ -1093,7 +1093,7 @@ def test_truncate_zeros_with_negative_exponent_numbers(self):
10931093
"""
10941094
input = { "ex:value": 0.97 }
10951095

1096-
expected = '_:b0 <ex:value> "9.7E-1"^^<http://www.w3.org/2001/XMLSchema#double> .\n'
1096+
expected = '_:b0 <ex:value> "9.7E-1"^^<http://www.w3.org/2001/XMLSchema#double> .\n\n'
10971097

10981098
nquads = jsonld.to_rdf(input, options={'format': 'application/n-quads'})
10991099
assert nquads == expected

0 commit comments

Comments
 (0)