File: test_issue1043.py

package info (click to toggle)
rdflib 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 38,248 kB
  • sloc: python: 39,216; sh: 153; makefile: 110
file content (31 lines) | stat: -rw-r--r-- 838 bytes parent folder | download
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
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)))
        g.print()
        sys.stdout = sys.__stdout__
        self.assertEqual(capturedOutput.getvalue(), expected)


if __name__ == "__main__":
    unittest.main()