<s> import sys , time , os <EOL> from django . conf import settings <EOL> from django . db import connection <EOL> from django . core import mail <EOL> from django . test import signals <EOL> from django . template import Template <EOL> from django . utils . translation import deactivate <EOL> def instrumented_test_render ( self , context ) : <EOL> """<STR_LIT>""" <EOL> signals . template_rendered . send ( sender = self , template = self , context = context ) <EOL> return self . nodelist . render ( context ) <EOL> class TestSMTPConnection ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( * args , ** kwargs ) : <EOL> pass <EOL> def open ( self ) : <EOL> "<STR_LIT>" <EOL> pass <EOL> def close ( self ) : <EOL> "<STR_LIT>" <EOL> pass <EOL> def send_messages ( self , messages ) : <EOL> "<STR_LIT>" <EOL> mail . outbox . extend ( messages ) <EOL> return len ( messages ) <EOL> def setup_test_environment ( ) : <EOL> """<STR_LIT>""" <EOL> Template . original_render = Template . render <EOL> Template . render = instrumented_test_render <EOL> mail . original_SMTPConnection = mail . SMTPConnection <EOL> mail . SMTPConnection = TestSMTPConnection <EOL> mail . outbox = [ ] <EOL> deactivate ( ) <EOL> def teardown_test_environment ( ) : <EOL> """<STR_LIT>""" <EOL> Template . render = Template . original_render <EOL> del Template . original_render <EOL> mail . SMTPConnection = mail . original_SMTPConnection <EOL> del mail . original_SMTPConnection <EOL> del mail . outbox </s>
