<s> from rdflib . term import Variable <EOL> from rdflib . namespace import RDF , RDFS <EOL> from rdflib . store import Store <EOL> from rdflib import plugin <EOL> from rdflib . parser import StringInputSource <EOL> from rdflib import Graph <EOL> import unittest , sys <EOL> import rdflib <EOL> """<STR_LIT>""" <EOL> class TestSPARQLToldBNodes ( unittest . TestCase ) : <EOL> known_issue = True <EOL> sparql = True <EOL> def setUp ( self ) : <EOL> NS = u"<STR_LIT>" <EOL> self . graph = Graph ( store ) <EOL> self . graph . parse ( StringInputSource ( """<STR_LIT>""" % ( RDF , RDFS ) ) , format = "<STR_LIT>" ) <EOL> def testToldBNode ( self ) : <EOL> for s , p , o in self . graph . triples ( ( None , RDF . type , None ) ) : <EOL> pass <EOL> query = """<STR_LIT>""" % s . n3 ( ) <EOL> print query <EOL> rt = self . graph . query ( query , DEBUG = debug ) <EOL> print list ( rt ) <EOL> self . failUnless ( len ( rt ) == <NUM_LIT:1> , "<STR_LIT>" % len ( rt ) ) <EOL> bindings = { Variable ( '<STR_LIT>' ) : s } <EOL> query = """<STR_LIT>""" <EOL> print query <EOL> rt = self . graph . query ( query , initBindings = bindings , DEBUG = debug ) <EOL> self . failUnless ( len ( rt ) == <NUM_LIT:1> , "<STR_LIT>" % ( len ( rt ) , s . n3 ( ) ) ) <EOL> def testFilterBNode ( self ) : <EOL> for s , p , o in self . graph . triples ( ( None , RDF . type , None ) ) : <EOL> pass <EOL> query2 = """<STR_LIT>""" % s . n3 ( ) <EOL> print query2 <EOL> rt = self . graph . query ( query2 , DEBUG = True ) <EOL> self . failUnless ( len ( rt ) == <NUM_LIT:1> , "<STR_LIT>" % ( len ( rt ) , s . n3 ( ) ) ) <EOL> def tearDown ( self ) : <EOL> self . graph . store . rollback ( ) <EOL> store = "<STR_LIT>" <EOL> debug = False <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from optparse import OptionParser <EOL> usage = '''<STR_LIT>''' <EOL> op = OptionParser ( usage = usage ) <EOL> op . add_option ( '<STR_LIT>' , '<STR_LIT>' , default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT:-c>' , '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = "<STR_LIT:store_true>" , default = False , <EOL> help = "<STR_LIT>" ) <EOL> ( options , args ) = op . parse_args ( ) <EOL> global store , debug <EOL> debug = options . debug <EOL> store = plugin . get ( options . storeKind , Store ) ( options . identifier ) <EOL> store . open ( options . config , create = False ) <EOL> suite = unittest . TestLoader ( ) . loadTestsFromTestCase ( TestSPARQLToldBNodes ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) </s>
