<s> """<STR_LIT>""" <EOL> import mock <EOL> import sys <EOL> import unittest <EOL> import six <EOL> class ReporterTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> from certbot import reporter <EOL> self . reporter = reporter . Reporter ( mock . MagicMock ( quiet = False ) ) <EOL> self . old_stdout = sys . stdout <EOL> sys . stdout = six . StringIO ( ) <EOL> def tearDown ( self ) : <EOL> sys . stdout = self . old_stdout <EOL> def test_multiline_message ( self ) : <EOL> self . reporter . add_message ( "<STR_LIT>" , self . reporter . LOW_PRIORITY ) <EOL> self . reporter . atexit_print_messages ( ) <EOL> output = sys . stdout . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> def test_tty_print_empty ( self ) : <EOL> sys . stdout . isatty = lambda : True <EOL> self . test_no_tty_print_empty ( ) <EOL> def test_no_tty_print_empty ( self ) : <EOL> self . reporter . print_messages ( ) <EOL> self . assertEqual ( sys . stdout . getvalue ( ) , "<STR_LIT>" ) <EOL> try : <EOL> raise ValueError <EOL> except ValueError : <EOL> self . reporter . print_messages ( ) <EOL> self . assertEqual ( sys . stdout . getvalue ( ) , "<STR_LIT>" ) <EOL> def test_atexit_print_messages ( self ) : <EOL> self . _add_messages ( ) <EOL> self . reporter . atexit_print_messages ( ) <EOL> output = sys . stdout . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> def test_tty_successful_exit ( self ) : <EOL> sys . stdout . isatty = lambda : True <EOL> self . _successful_exit_common ( ) <EOL> def test_no_tty_successful_exit ( self ) : <EOL> self . _successful_exit_common ( ) <EOL> def test_tty_unsuccessful_exit ( self ) : <EOL> sys . stdout . isatty = lambda : True <EOL> self . _unsuccessful_exit_common ( ) <EOL> def test_no_tty_unsuccessful_exit ( self ) : <EOL> self . _unsuccessful_exit_common ( ) <EOL> def _successful_exit_common ( self ) : <EOL> self . _add_messages ( ) <EOL> self . reporter . print_messages ( ) <EOL> output = sys . stdout . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> def _unsuccessful_exit_common ( self ) : <EOL> self . _add_messages ( ) <EOL> try : <EOL> raise ValueError <EOL> except ValueError : <EOL> self . reporter . print_messages ( ) <EOL> output = sys . stdout . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" in output ) <EOL> self . assertTrue ( "<STR_LIT>" not in output ) <EOL> self . assertTrue ( "<STR_LIT>" not in output ) <EOL> def _add_messages ( self ) : <EOL> self . reporter . add_message ( "<STR_LIT>" , self . reporter . HIGH_PRIORITY ) <EOL> self . reporter . add_message ( <EOL> "<STR_LIT>" , self . reporter . MEDIUM_PRIORITY , on_crash = False ) <EOL> self . reporter . add_message ( <EOL> "<STR_LIT>" , self . reporter . LOW_PRIORITY , on_crash = False ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
