<s> import io <EOL> import email <EOL> import unittest <EOL> from email . message import Message <EOL> from test . test_email import TestEmailBase <EOL> class TestCustomMessage ( TestEmailBase ) : <EOL> class MyMessage ( Message ) : <EOL> def __init__ ( self , policy ) : <EOL> self . check_policy = policy <EOL> super ( ) . __init__ ( ) <EOL> MyPolicy = TestEmailBase . policy . clone ( linesep = '<STR_LIT>' ) <EOL> def test_custom_message_gets_policy_if_possible_from_string ( self ) : <EOL> msg = email . message_from_string ( "<STR_LIT>" , <EOL> self . MyMessage , <EOL> policy = self . MyPolicy ) <EOL> self . assertTrue ( isinstance ( msg , self . MyMessage ) ) <EOL> self . assertIs ( msg . check_policy , self . MyPolicy ) <EOL> def test_custom_message_gets_policy_if_possible_from_file ( self ) : <EOL> source_file = io . StringIO ( "<STR_LIT>" ) <EOL> msg = email . message_from_file ( source_file , <EOL> self . MyMessage , <EOL> policy = self . MyPolicy ) <EOL> self . assertTrue ( isinstance ( msg , self . MyMessage ) ) <EOL> self . assertIs ( msg . check_policy , self . MyPolicy ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
