<s> from __future__ import unicode_literals <EOL> import functools <EOL> from . import base <EOL> class TestCase ( base . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def assertMessage ( self , response , content , level = None , tags = None , <EOL> limit = None ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( <EOL> hasattr ( response , "<STR_LIT>" ) and response . context , <EOL> "<STR_LIT>" ) <EOL> messages = list ( <EOL> response . context [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in response . context <EOL> else [ ] ) <EOL> self . assertTrue ( <EOL> bool ( messages ) , <EOL> "<STR_LIT>" ) <EOL> if limit : <EOL> self . assertGreaterEqual ( <EOL> limit , len ( messages ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( <EOL> limit = limit , actual = len ( messages ) ) ) <EOL> self . assertTrue ( <EOL> any ( ( <EOL> message . message == content and <EOL> ( not level or message . level == level ) and <EOL> ( not tags or ( <EOL> set ( tag . strip ( ) <EOL> for tag in ( message . tags or "<STR_LIT>" ) . split ( "<STR_LIT:U+0020>" ) <EOL> if tag ) == set ( tag . strip ( ) <EOL> for tag in ( tags or "<STR_LIT>" ) . split ( "<STR_LIT:U+0020>" ) <EOL> if tag ) ) ) ) <EOL> for message in messages ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def assertNoMessages ( self , response ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( response , "<STR_LIT>" , None ) : <EOL> self . assertEqual ( <EOL> len ( list ( <EOL> response . context [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in response . context <EOL> else [ ] ) ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" ) <EOL> def create_message_assertions ( self , content = None , level = None , tags = None , <EOL> limit = None ) : <EOL> """<STR_LIT>""" <EOL> return ( <EOL> ( functools . partial ( self . assertMessage , <EOL> content = content , level = level , tags = tags , limit = limit ) , ) <EOL> if content is not None <EOL> else ( self . assertNoMessages , ) ) <EOL> def create_response_assertions ( self , message = None , message_level = None , <EOL> message_tags = None , message_limit = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return ( <EOL> self . create_message_assertions ( <EOL> content = message , <EOL> level = message_level , <EOL> tags = message_tags , <EOL> limit = message_limit ) + <EOL> super ( TestCase , self ) . create_response_assertions ( ** kwargs ) ) </s>
