-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added test case for #1043 * Don't make XSD.Decimal pretty during serialization
- Loading branch information
1 parent
231bc6d
commit c7c4e15
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import decimal | ||
import unittest | ||
import io | ||
import sys | ||
|
||
from rdflib import Graph, Namespace, XSD, RDFS, Literal | ||
|
||
|
||
class TestIssue1043(unittest.TestCase): | ||
|
||
def test_issue_1043(self): | ||
expected = """@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
<http://example.org/number> rdfs:label 4e-08 . | ||
""" | ||
capturedOutput = io.StringIO() | ||
sys.stdout = capturedOutput | ||
g = Graph() | ||
g.bind('xsd', XSD) | ||
g.bind('rdfs', RDFS) | ||
n = Namespace("http://example.org/") | ||
g.add((n.number, RDFS.label, Literal(0.00000004, datatype=XSD.decimal))) | ||
print(g.serialize(format="turtle").decode("utf-8")) | ||
sys.stdout = sys.__stdout__ | ||
self.assertEqual(capturedOutput.getvalue(), expected) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |