<s> import unittest <EOL> import rdflib <EOL> import re <EOL> from rdflib . py3compat import b <EOL> TRIPLE = ( rdflib . URIRef ( "<STR_LIT>" ) , <EOL> rdflib . RDFS . label , <EOL> rdflib . Literal ( "<STR_LIT>" ) ) <EOL> class TestTrig ( unittest . TestCase ) : <EOL> def testEmpty ( self ) : <EOL> g = rdflib . Graph ( ) <EOL> s = g . serialize ( format = '<STR_LIT>' ) <EOL> self . assertTrue ( s is not None ) <EOL> def testRepeatTriples ( self ) : <EOL> g = rdflib . ConjunctiveGraph ( ) <EOL> g . get_context ( '<STR_LIT>' ) . add ( ( rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) ) ) <EOL> g . get_context ( '<STR_LIT>' ) . add ( ( rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( len ( g . get_context ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( g . get_context ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> s = g . serialize ( format = '<STR_LIT>' ) <EOL> self . assert_ ( b ( '<STR_LIT:{}>' ) not in s ) <EOL> def testSameSubject ( self ) : <EOL> g = rdflib . ConjunctiveGraph ( ) <EOL> g . get_context ( '<STR_LIT>' ) . add ( ( rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) ) ) <EOL> g . get_context ( '<STR_LIT>' ) . add ( ( rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) , <EOL> rdflib . URIRef ( '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( len ( g . get_context ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( g . get_context ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> s = g . serialize ( format = '<STR_LIT>' ) <EOL> self . assertEqual ( len ( re . findall ( b ( "<STR_LIT>" ) , s ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( re . findall ( b ( "<STR_LIT>" ) , s ) ) , <NUM_LIT:1> ) <EOL> self . assert_ ( b ( '<STR_LIT:{}>' ) not in s ) <EOL> def testRememberNamespace ( self ) : <EOL> g = rdflib . ConjunctiveGraph ( ) <EOL> g . add ( TRIPLE + ( rdflib . URIRef ( "<STR_LIT>" ) , ) ) <EOL> first_out = g . serialize ( format = '<STR_LIT>' ) <EOL> second_out = g . serialize ( format = '<STR_LIT>' ) <EOL> self . assert_ ( b'<STR_LIT>' in second_out ) <EOL> self . assert_ ( b'<STR_LIT>' in first_out ) <EOL> def testGraphQnameSyntax ( self ) : <EOL> g = rdflib . ConjunctiveGraph ( ) <EOL> g . add ( TRIPLE + ( rdflib . URIRef ( "<STR_LIT>" ) , ) ) <EOL> out = g . serialize ( format = '<STR_LIT>' ) <EOL> self . assert_ ( b'<STR_LIT>' in out ) <EOL> def testGraphUriSyntax ( self ) : <EOL> g = rdflib . ConjunctiveGraph ( ) <EOL> g . add ( TRIPLE + ( rdflib . URIRef ( "<STR_LIT>" ) , ) ) <EOL> out = g . serialize ( format = '<STR_LIT>' ) <EOL> self . assert_ ( b'<STR_LIT>' in out ) <EOL> def testBlankGraphIdentifier ( self ) : <EOL> g = rdflib . ConjunctiveGraph ( ) <EOL> g . add ( TRIPLE + ( rdflib . BNode ( ) , ) ) <EOL> out = g . serialize ( format = '<STR_LIT>' ) <EOL> graph_label_line = out . splitlines ( ) [ - <NUM_LIT:4> ] <EOL> self . assert_ ( re . match ( br'<STR_LIT>' , graph_label_line ) ) </s>
