def test_die(self): self.mox.StubOutWithMock(sys, 'stderr') self.mox.StubOutWithMock(sys, 'exit') sys.stderr.write('Test message') sys.stderr.write('\n') sys.exit(1) self.mox.ReplayAll() command.die('%s %s', 'Test', 'message')
def test_show_help(self): self.mox.StubOutWithMock(command, 'die') command.die(mox.IsA(basestring)) self.mox.ReplayAll() command.show_help(['test'])
def test_set_var_wrong_name(self): command.die(mox.IsA(basestring), 'invitations', 'disabled') \ .AndRaise(SystemExit) self.mox.ReplayAll() self.assertRaises(SystemExit, command.set_var, ['test', 'set', 'invitations.disabled', 'false'])
def test_main_catches(self): command.show_help(['test']).AndRaise(RuntimeError('catch me')) command.die('Failed: %s', mox.IsA(RuntimeError)) self.mox.ReplayAll() command.main(['test'])
def test_set_var_bad_name(self): command.die(mox.StrContains('parameter'), 'invitations') \ .AndRaise(SystemExit) self.mox.ReplayAll() self.assertRaises(SystemExit, command.set_var, ['test', 'set', 'invitations', 'true'])