<s> import unittest <EOL> from rdflib import OWL , RDF , Graph , Namespace <EOL> import rdflib <EOL> xmldata = """<STR_LIT>""" <EOL> q = """<STR_LIT>""" <EOL> p = """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> def query ( graph , querystring ) : <EOL> processor = rdflib . plugin . get ( '<STR_LIT>' , rdflib . query . Processor ) ( graph ) <EOL> result = rdflib . plugin . get ( '<STR_LIT>' , rdflib . query . Result ) <EOL> ns = dict ( graph . namespace_manager . namespaces ( ) ) <EOL> return result ( processor . query ( querystring , initNs = ns ) ) <EOL> class TestSPARQLQueryinitNs ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . graph = Graph ( ) <EOL> self . graph . parse ( data = xmldata ) <EOL> self . expect = set ( [ x for x , _ , _ in self . graph . triples ( <EOL> ( None , RDF [ '<STR_LIT:type>' ] , OWL [ '<STR_LIT>' ] ) ) ] ) <EOL> def testnoprefix ( self ) : <EOL> ns = { u'<STR_LIT>' : Namespace ( "<STR_LIT>" ) , <EOL> u'<STR_LIT>' : Namespace ( "<STR_LIT>" ) } <EOL> got = set ( [ x for ( x , ) in self . graph . query ( q , initNs = ns , DEBUG = True ) ] ) <EOL> assert self . expect == got , ( self . expect , got ) </s>
