def test_stock_trailing_prompt(self): with patch('sys.stderr', new=StringIO()) as fake_stderr: diagnosticism.set_program_name('myprog1') abort('over and out!', do_exit=False, trailing_prompt=True) self.assertEqual('myprog1: over and out!; use --help for usage\n', fake_stderr.getvalue())
def test_default(self): with patch('sys.stderr', new=StringIO()) as fake_stderr: diagnosticism.set_program_name('myprog1') abort('over and out!', do_exit=False) self.assertEqual('myprog1: over and out!\n', fake_stderr.getvalue())
def test_explicit_trailing_prompt(self): with patch('sys.stderr', new=StringIO()) as fake_stderr: diagnosticism.set_program_name('myprog1') abort('over and out!', do_exit=False, trailing_prompt='get over yourself!') self.assertEqual('myprog1: over and out!; get over yourself!\n', fake_stderr.getvalue())
def test_set_default_trailing_prompt(self): with patch('sys.stderr', new=StringIO()) as fake_stderr: diagnosticism.set_program_name('myprog1') set_default_trailing_prompt('ok, now') abort('over and out!', do_exit=False, trailing_prompt=True) set_default_trailing_prompt(None) self.assertEqual('myprog1: over and out!; ok, now\n', fake_stderr.getvalue())