<s> """<STR_LIT>""" <EOL> from unittest import TestCase <EOL> from django . template import ( TokenParser , FilterExpression , Parser , Variable , <EOL> TemplateSyntaxError ) <EOL> class ParserTests ( TestCase ) : <EOL> def test_token_parsing ( self ) : <EOL> p = TokenParser ( "<STR_LIT>" ) <EOL> self . assertEqual ( p . tagname , "<STR_LIT>" ) <EOL> self . assertEqual ( p . value ( ) , "<STR_LIT>" ) <EOL> self . assertTrue ( p . more ( ) ) <EOL> self . assertEqual ( p . tag ( ) , "<STR_LIT>" ) <EOL> self . assertFalse ( p . more ( ) ) <EOL> p = TokenParser ( '<STR_LIT>' ) <EOL> self . assertEqual ( p . tagname , "<STR_LIT>" ) <EOL> self . assertEqual ( p . value ( ) , '<STR_LIT>' ) <EOL> self . assertTrue ( p . more ( ) ) <EOL> self . assertEqual ( p . tag ( ) , "<STR_LIT>" ) <EOL> self . assertFalse ( p . more ( ) ) <EOL> p = TokenParser ( "<STR_LIT>" ) <EOL> self . assertEqual ( p . tagname , "<STR_LIT>" ) <EOL> self . assertEqual ( p . value ( ) , "<STR_LIT>" ) <EOL> self . assertTrue ( p . more ( ) ) <EOL> self . assertEqual ( p . tag ( ) , "<STR_LIT>" ) <EOL> self . assertFalse ( p . more ( ) ) <EOL> def test_filter_parsing ( self ) : <EOL> c = { "<STR_LIT>" : { "<STR_LIT>" : u"<STR_LIT>" } } <EOL> p = Parser ( "<STR_LIT>" ) <EOL> def fe_test ( s , val ) : <EOL> self . assertEqual ( FilterExpression ( s , p ) . resolve ( c ) , val ) <EOL> fe_test ( "<STR_LIT>" , u"<STR_LIT>" ) <EOL> fe_test ( "<STR_LIT>" , u"<STR_LIT>" ) <EOL> fe_test ( u'<STR_LIT>' , u"<STR_LIT>" ) <EOL> fe_test ( u"<STR_LIT>" , u"<STR_LIT>" ) <EOL> fe_test ( ur '<STR_LIT>' , u'<STR_LIT>' ) <EOL> fe_test ( ur '<STR_LIT>' , u'<STR_LIT>' ) <EOL> fe_test ( ur "<STR_LIT>" , u"<STR_LIT>" ) <EOL> fe = FilterExpression ( ur '<STR_LIT>' , p ) <EOL> self . assertEqual ( fe . filters , [ ] ) <EOL> self . assertEqual ( fe . var , u'<STR_LIT>' ) <EOL> self . assertRaises ( TemplateSyntaxError , <EOL> FilterExpression , "<STR_LIT>" , p <EOL> ) <EOL> def test_variable_parsing ( self ) : <EOL> c = { "<STR_LIT>" : { "<STR_LIT>" : u"<STR_LIT>" } } <EOL> self . assertEqual ( Variable ( "<STR_LIT>" ) . resolve ( c ) , "<STR_LIT>" ) <EOL> self . assertEqual ( Variable ( u'<STR_LIT>' ) . resolve ( c ) , "<STR_LIT>" ) <EOL> self . assertEqual ( Variable ( u"<STR_LIT>" ) . resolve ( c ) , "<STR_LIT>" ) <EOL> self . assertEqual ( Variable ( "<STR_LIT>" ) . resolve ( c ) , "<STR_LIT>" ) <EOL> self . assertEqual ( Variable ( '<STR_LIT>' ) . resolve ( c ) , "<STR_LIT>" ) <EOL> self . assertEqual ( Variable ( "<STR_LIT>" ) . resolve ( c ) , "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> Variable ( ur '<STR_LIT>' ) . resolve ( c ) , '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> Variable ( ur "<STR_LIT>" ) . resolve ( c ) , "<STR_LIT>" <EOL> ) <EOL> self . assertRaises ( TemplateSyntaxError , <EOL> Variable , "<STR_LIT>" <EOL> ) </s>
