<s> import binascii <EOL> import unittest <EOL> from dns . exception import DNSException <EOL> class FormatedError ( DNSException ) : <EOL> fmt = "<STR_LIT>" <EOL> supp_kwargs = set ( [ '<STR_LIT>' ] ) <EOL> class ExceptionTestCase ( unittest . TestCase ) : <EOL> def test_custom_message ( self ) : <EOL> msg = "<STR_LIT>" <EOL> try : <EOL> raise DNSException ( msg ) <EOL> except DNSException as ex : <EOL> self . assertEqual ( str ( ex ) , msg ) <EOL> def test_implicit_message ( self ) : <EOL> try : <EOL> raise DNSException ( ) <EOL> except DNSException as ex : <EOL> self . assertEqual ( ex . __class__ . __doc__ , str ( ex ) ) <EOL> def test_formatted_error ( self ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : '<STR_LIT:value>' } <EOL> try : <EOL> raise FormatedError ( ** params ) <EOL> except FormatedError as ex : <EOL> msg = FormatedError . fmt . format ( ** params ) <EOL> self . assertEqual ( msg , str ( ex ) ) <EOL> def test_kwargs_only ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( AssertionError ) : <EOL> raise FormatedError ( <NUM_LIT:1> , a = <NUM_LIT:2> ) <EOL> def test_kwargs_unsupported ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( AssertionError ) : <EOL> raise FormatedError ( unsupported = <NUM_LIT:2> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
