File: test_issue363.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 (44 lines) | stat: -rw-r--r-- 1,247 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
32
33
34
35
36
37
38
39
40
41
42
43
44
import pytest
import rdflib

data = """<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:http="http://www.w3.org/2011/http#">

    <http:HeaderElement rdf:about="#he0">
        <http:params>
            <http:Parameter rdf:about="#param0_0" />
            <http:Parameter rdf:about="#param0_1" />
        </http:params>
    </http:HeaderElement>

</rdf:RDF>
"""

data2 = """<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://www.example.org/meeting_organization#">

    <rdf:Description about="http://meetings.example.com/cal#m1">
        <Location rdf:parseType="Resource">
            <zip xmlns="http://www.another.example.org/geographical#">02139</zip>
            <lat xmlns="http://www.another.example.org/geographical#">14.124425</lat>
        </Location>
    </rdf:Description>
</rdf:RDF>
"""


def test_broken_rdfxml():
    with pytest.raises(Exception):
        rdflib.Graph().parse(data=data)


def test_parsetype_resource():
    g = rdflib.Graph().parse(data=data2, format="xml")
    print(g.serialize(format="n3"))


if __name__ == "__main__":
    test_broken_rdfxml()
    test_parsetype_resource()