def test_run_test_list(self):
        self.patch_object(lc_test, 'run_unittest')
        self.patch_object(lc_test, 'run_direct')
        self.patch_object(lc_test.utils, 'get_class')

        class TestClassOne():

            def run(self):
                return

        class TestClassTwo():

            test_runner = 'direct'

            def run(self):
                return

        test_classes = {
            'TestClassOne': TestClassOne,
            'TestClassTwo': TestClassTwo}
        self.get_class.side_effect = lambda x: test_classes[x]
        lc_test.run_test_list(['TestClassOne', 'TestClassTwo'])
        self.run_unittest.assert_called_once_with(
            TestClassOne,
            'TestClassOne')
        self.run_direct.assert_called_once_with(
            TestClassTwo,
            'TestClassTwo')
Пример #2
0
 def test_run_test_list(self):
     loader_mock = mock.MagicMock()
     runner_mock = mock.MagicMock()
     self.patch_object(lc_test.unittest, 'TestLoader')
     self.patch_object(lc_test.unittest, 'TextTestRunner')
     self.TestLoader.return_value = loader_mock
     self.TextTestRunner.return_value = runner_mock
     self.patch_object(lc_test.utils, 'get_class')
     self.get_class.side_effect = lambda x: x
     test_class1_mock = mock.MagicMock()
     test_class2_mock = mock.MagicMock()
     lc_test.run_test_list([test_class1_mock, test_class2_mock])
     loader_calls = [
         mock.call(test_class1_mock),
         mock.call(test_class2_mock)
     ]
     loader_mock.loadTestsFromTestCase.assert_has_calls(loader_calls)
Пример #3
0
 def test_test(self):
     self.patch_object(lc_test, 'run_test_list')
     lc_test.run_test_list(['test_class1', 'test_class2'])
     self.run_test_list.assert_called_once_with(
         ['test_class1', 'test_class2'])