Exemple #1
0
 def test__run_num_repeat(self):
     num_repeat_tests = 3
     queue = _queue.Queue()
     suite_options = self.get_suite_options(num_repeat_tests=num_repeat_tests)
     mock_time = MockTime(1)
     job_object = UnitJob(suite_options)
     self.queue_tests(self.TESTS, queue, queue_element.QueueElemRepeatNum, suite_options)
     job_object._get_time = mock_time.time
     job_object._run(queue, self.mock_interrupt_flag())
     self.assertEqual(job_object.total_test_num, num_repeat_tests * len(self.TESTS))
     for test in self.TESTS:
         self.assertEqual(job_object.tests[test], num_repeat_tests)
Exemple #2
0
    def __assert_when_run_tests(self,
                                setup_succeeded=True,
                                teardown_succeeded=True):
        queue = _queue.Queue()
        interrupt_flag = threading.Event()
        setup_flag = threading.Event()
        teardown_flag = threading.Event()

        self.__job_object(queue, interrupt_flag, setup_flag, teardown_flag)

        self.assertEqual(setup_succeeded, not interrupt_flag.is_set())
        self.assertEqual(teardown_succeeded, not teardown_flag.is_set())
Exemple #3
0
 def test__run_time_repeat_time_no_min_max(self):
     increment = 1
     time_repeat_tests_secs = 10
     expected_tests_run = self.expected_run_num(time_repeat_tests_secs, increment)
     queue = _queue.Queue()
     suite_options = self.get_suite_options(time_repeat_tests_secs=time_repeat_tests_secs)
     mock_time = MockTime(increment)
     job_object = UnitJob(suite_options)
     self.queue_tests(self.TESTS, queue, queue_element.QueueElemRepeatTime, suite_options)
     job_object._get_time = mock_time.time
     job_object._run(queue, self.mock_interrupt_flag())
     self.assertEqual(job_object.total_test_num, expected_tests_run * len(self.TESTS))
     for test in self.TESTS:
         self.assertEqual(job_object.tests[test], expected_tests_run)
Exemple #4
0
    def __assert_when_run_tests(self, setup_succeeded=True, teardown_succeeded=True):
        queue = _queue.Queue()
        interrupt_flag = threading.Event()
        setup_flag = threading.Event()
        teardown_flag = threading.Event()

        self.__job_object(queue, interrupt_flag, setup_flag, teardown_flag)

        self.assertEqual(setup_succeeded, not interrupt_flag.is_set())
        self.assertEqual(setup_succeeded, not setup_flag.is_set())
        self.assertEqual(teardown_succeeded, not teardown_flag.is_set())

        # teardown_fixture() should be called even if setup_fixture() raises an exception.
        self.__job_object.setup_fixture.assert_called()
        self.__job_object.teardown_fixture.assert_called()
Exemple #5
0
 def test__run_time_repeat_time_no_min_max(self):
     delay = 0.1
     time_repeat_tests_secs = 1
     expected_tests_run = self.expected_run_num(time_repeat_tests_secs,
                                                delay)
     queue = _queue.Queue()
     suite_options = self.get_suite_options(
         time_repeat_tests_secs=time_repeat_tests_secs)
     job_object = UnitJob(suite_options, {}, delay=delay)
     self.queue_tests(self.TESTS, queue, queue_element.QueueElemRepeatTime,
                      suite_options)
     job_object._run(queue, self.mock_interrupt_flag())
     self.assertGreaterEqual(job_object.total_test_num,
                             expected_tests_run * len(self.TESTS))
     for test in self.TESTS:
         self.assertGreaterEqual(job_object.tests[test], expected_tests_run)
Exemple #6
0
 def test__run_time_repeat_min(self):
     increment = 1
     time_repeat_tests_secs = 2
     num_repeat_tests_min = 3
     num_repeat_tests_max = 100
     queue = _queue.Queue()
     suite_options = self.get_suite_options(time_repeat_tests_secs=time_repeat_tests_secs,
                                            num_repeat_tests_min=num_repeat_tests_min,
                                            num_repeat_tests_max=num_repeat_tests_max)
     mock_time = MockTime(increment)
     job_object = UnitJob(suite_options)
     self.queue_tests(self.TESTS, queue, queue_element.QueueElemRepeatTime, suite_options)
     job_object._get_time = mock_time.time
     job_object._run(queue, self.mock_interrupt_flag())
     self.assertEqual(job_object.total_test_num, num_repeat_tests_min * len(self.TESTS))
     for test in self.TESTS:
         self.assertEqual(job_object.tests[test], num_repeat_tests_min)
Exemple #7
0
 def test__run_time_repeat_max(self):
     increment = 1
     time_repeat_tests_secs = 30
     num_repeat_tests_min = 1
     num_repeat_tests_max = 10
     expected_time_repeat_tests = self.expected_run_num(time_repeat_tests_secs, increment)
     queue = _queue.Queue()
     suite_options = self.get_suite_options(time_repeat_tests_secs=time_repeat_tests_secs,
                                            num_repeat_tests_min=num_repeat_tests_min,
                                            num_repeat_tests_max=num_repeat_tests_max)
     mock_time = MockTime(increment)
     job_object = UnitJob(suite_options)
     self.queue_tests(self.TESTS, queue, queue_element.QueueElemRepeatTime, suite_options)
     with mock.patch("time.time", side_effect=mock_time.time):
         job_object._run(queue, self.mock_interrupt_flag())
     self.assertEqual(job_object.total_test_num, num_repeat_tests_max * len(self.TESTS))
     for test in self.TESTS:
         self.assertEqual(job_object.tests[test], num_repeat_tests_max)
         self.assertLess(job_object.tests[test], expected_time_repeat_tests)