Пример #1
0
    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')
Пример #2
0
    def test_show_help(self):
        self.mox.StubOutWithMock(command, 'die')
        command.die(mox.IsA(basestring))

        self.mox.ReplayAll()
        command.show_help(['test'])
Пример #3
0
 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'])
Пример #4
0
 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'])
Пример #5
0
 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'])