from rdflib.graph import Graph
from rdflib.namespace import RDF, RDFS
from rdflib.term import Literal, URIRef
class TestParser:
backend = "default"
path = "store"
def setup_method(self):
self.graph = Graph(store=self.backend)
self.graph.open(self.path)
def teardown_method(self):
self.graph.close()
def testNoPathWithHash(self):
g = self.graph
g.parse(
data="""\
testing
""",
format="xml",
publicID="http://example.org",
)
subject = URIRef("http://example.org#")
label = g.value(subject, RDFS.label)
assert label == Literal("testing")
type = g.value(subject, RDF.type)
assert type == RDFS.Class
class TestGitHubIssues:
def test_issue_1228_a(self):
data = """
PREFIX sdo:
PREFIX xsd:
sdo:startDate "1982"^^xsd:gYear .
"""
g = Graph().parse(data=data, format="ttl")
assert "1982-01-01" not in data
assert "1982-01-01" not in g.serialize(format="ttl")
def test_issue_1228_b(self):
data = """\
1982
"""
g = Graph().parse(data=data, format="xml")
assert "1982-01-01" not in data
assert "1982-01-01" not in g.serialize(format="xml")
def test_issue_806(self):
data = (
" "
" "
'"1891"^^ .'
)
g = Graph()
g.parse(data=data, format="nt")
for _, _, o in g:
assert "1891-01-01" not in o.n3()