예제 #1
0
파일: test_main.py 프로젝트: klmitch/timid
    def test_change_result(self, mock_print_exc, mock_activate, mock_Context):
        ctxt = mock_Context.return_value
        exts = mock_activate.return_value
        args = mock.Mock(directory='directory', debug=False,
                         environment={}, variables={})

        gen = main._processor(args)
        next(gen)

        self.assertEqual(args.ctxt, ctxt)
        self.assertEqual(args.exts, exts)
        self.assertEqual(ctxt.environment, {})
        self.assertEqual(ctxt.variables, {})
        self.assertFalse(mock_print_exc.called)
        self.assertFalse(exts.finalize.called)

        result = gen.send(None)

        self.assertEqual(result, 'alt result')
        self.assertFalse(mock_print_exc.called)
        exts.finalize.assert_called_once_with(ctxt, None)
예제 #2
0
파일: test_main.py 프로젝트: klmitch/timid
    def test_exception(self, mock_print_exc, mock_activate, mock_Context):
        ctxt = mock_Context.return_value
        exts = mock_activate.return_value
        args = mock.Mock(directory='directory', debug=False,
                         environment={}, variables={})

        gen = main._processor(args)
        next(gen)

        self.assertEqual(args.ctxt, ctxt)
        self.assertEqual(args.exts, exts)
        self.assertEqual(ctxt.environment, {})
        self.assertEqual(ctxt.variables, {})
        self.assertFalse(mock_print_exc.called)
        self.assertFalse(exts.finalize.called)

        exc = TestingException('test failure')
        result = gen.throw(exc)

        self.assertEqual(result, 'test failure')
        self.assertFalse(mock_print_exc.called)
        exts.finalize.assert_called_once_with(ctxt, exc)
예제 #3
0
파일: test_main.py 프로젝트: klmitch/timid
    def test_vars(self, mock_print_exc, mock_activate, mock_Context):
        ctxt = mock_Context.return_value
        exts = mock_activate.return_value
        args = mock.Mock(directory='directory', debug=False,
                         environment={'c': 'z', 'd': 0},
                         variables={'x': 'c', 'w': 0})

        gen = main._processor(args)
        next(gen)

        self.assertEqual(args.ctxt, ctxt)
        self.assertEqual(args.exts, exts)
        self.assertEqual(ctxt.environment, {'a': 1, 'b': 2, 'c': 'z', 'd': 0})
        self.assertEqual(ctxt.variables, {'x': 'c', 'y': 2, 'z': 1, 'w': 0})
        self.assertFalse(mock_print_exc.called)
        self.assertFalse(exts.finalize.called)

        result = gen.send(None)

        self.assertEqual(result, None)
        self.assertFalse(mock_print_exc.called)
        exts.finalize.assert_called_once_with(ctxt, None)