<s> import unittest <EOL> from rdflib import plugin <EOL> from rdflib . namespace import Namespace , RDF , RDFS <EOL> from rdflib . term import URIRef <EOL> from rdflib . store import Store <EOL> from cStringIO import StringIO <EOL> from rdflib import Graph <EOL> import rdflib <EOL> try : <EOL> set <EOL> except NameError : <EOL> from sets import Set as set <EOL> testGraph1N3 = """<STR_LIT>""" <EOL> sparqlQ1 = """<STR_LIT>""" <EOL> sparqlQ2 = """<STR_LIT>""" <EOL> sparqlQ3 = """<STR_LIT>""" <EOL> sparqlQ4 = """<STR_LIT>""" <EOL> class AdvancedTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> memStore = plugin . get ( '<STR_LIT>' , Store ) ( ) <EOL> self . testGraph = Graph ( memStore ) <EOL> self . testGraph . parse ( StringIO ( testGraph1N3 ) , format = '<STR_LIT>' ) <EOL> def testNamedGraph ( self ) : <EOL> OWL_NS = Namespace ( "<STR_LIT>" ) <EOL> rt = self . testGraph . query ( sparqlQ4 ) <EOL> self . assertEquals ( set ( rt ) , set ( ( x , ) for x in [ OWL_NS . DatatypeProperty , OWL_NS . ObjectProperty , OWL_NS . OntologyProperty , OWL_NS . Class , OWL_NS . Ontology , OWL_NS . AnnotationProperty , RDF . Property , RDFS . Class ] ) ) <EOL> def testScopedBNodes ( self ) : <EOL> rt = self . testGraph . query ( sparqlQ1 ) <EOL> self . assertEquals ( list ( rt ) [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , URIRef ( "<STR_LIT>" ) ) <EOL> def testCollectionContentWithinAndWithout ( self ) : <EOL> rt = self . testGraph . query ( sparqlQ3 ) <EOL> self . assertEquals ( list ( rt ) [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , URIRef ( "<STR_LIT>" ) ) <EOL> def testCollectionAsObject ( self ) : <EOL> rt = self . testGraph . query ( sparqlQ2 ) <EOL> self . assertEquals ( list ( rt ) [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , URIRef ( "<STR_LIT>" ) ) <EOL> self . assertEquals ( <NUM_LIT:1> , len ( rt ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> suite = unittest . makeSuite ( AdvancedTests ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:3> ) . run ( suite ) </s>
