Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (21 sloc) 1.026 kB
from unittest import TestCase
from rdflib import Graph, URIRef, Namespace, RDF, BNode
import rdflib_microdata
class MicrodataParserTest(TestCase):
def test_parse(self):
g = Graph()
g.parse(open("example.html"), format="microdata")
g.serialize(open("example.rdf", "w"))
# seem to be the right amount of assertions?
self.assertEqual(len(g), 15)
# is there an person?
s = URIRef("")
person = Namespace("")
self.assertEqual(g.value(s, RDF.type), URIRef(""))
self.assertEqual(g.value(s, person.telephone), "(425) 123-4567")
# is the person attached to an address?
addr = Namespace("")
a = BNode(g.value(s, person.address))
self.assertEqual(g.value(a, RDF.type), URIRef(""))
self.assertEqual(g.value(a, addr.postalCode), "98052")
# TODO: test dates?
Jump to Line
Something went wrong with that request. Please try again.