Ejemplo n.º 1
0
 def test_stop_suite_stop_timer_for_Suite(self):
     clear()
     test_suite = TestSuite.get_instance()
     test_suite.start_suite()
     test_suite.stop_suite()
     self.assertTrue(test_suite.timer.end_time > 0)
     self.assertTrue(test_suite.suite_duration() >= 0)
Ejemplo n.º 2
0
 def test_filter_tests_TestSuite_must_clear_if_not_present(self):
     clear()
     suite = TestSuite.get_instance()
     suite.get_or_create('gr_name').add_test(Test('a__2', print))
     suite.get_or_create('gr_name').add_test(Test('a__3', print))
     suite.filter_tests('b')
     self.assertEqual(0, suite.tests_count())
Ejemplo n.º 3
0
 def test_filter_tests_TestSuite_must_be_one(self):
     clear()
     suite = TestSuite.get_instance()
     suite.get_or_create('gr_name').add_test(Test('a__2', print))
     suite.get_or_create('gr_name').add_test(Test('a__3', print))
     suite.filter_tests('2')
     self.assertEqual(1, suite.tests_count())
Ejemplo n.º 4
0
 def test_filter_TestSuite(self):
     clear()
     suite = TestSuite.get_instance()
     suite.get_or_create("a")
     suite.get_or_create("b")
     suite.filter_groups(['a'])
     self.assertEqual(list(suite.groups), ['a'])
Ejemplo n.º 5
0
 def test_is_empty_TestSuite(self):
     clear()
     suite = TestSuite.get_instance()
     suite.groups.clear()
     self.assertTrue(suite.is_empty())
     suite.get_or_create('gr_name').add_test(Test('test', print))
     self.assertFalse(suite.is_empty())
Ejemplo n.º 6
0
 def test_empty_suite_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_empty_suite = inc
     count = COUNT
     r_.start(listener=listener_)
     self.assertEqual(count + 1, COUNT)
Ejemplo n.º 7
0
 def test_name_param_works(self):
     clear()
     test(name='new_name')(valid)
     self.assertTrue('new_name' in [
         t.name
         for t in list(TestSuite.get_instance().groups.values())[0].tests
     ])
Ejemplo n.º 8
0
 def test_parallel(self):
     clear()
     test(groups=('one', ))(half_second)
     test(groups=('two', ))(half_second)
     st = time()
     start(listener=Listener(0), threads=2)
     self.assertTrue(time() - st < 1)
Ejemplo n.º 9
0
 def test_raises_when_no_provider(self):
     clear()
     test(data_provider="missing")(valid_for_provider)
     with self.assertRaises(UnknownProviderName) as e:
         start(TestSuite.get_instance(), listener=Listener(0))
     self.assertTrue("Could not find provider(s) named ['missing']" in
                     e.exception.args[0])
Ejemplo n.º 10
0
    def test_data_function_must_have_return_fail(self):
        def fail():
            pass

        clear()
        with self.assertRaises(WrongDecoratedObject):
            provider(name='text')(fail)
Ejemplo n.º 11
0
 def test_before_all_when_before_last(self):
     clear()
     t = Test('second', print)
     TestSuite.get_instance().get_or_create("new").add_test(t)
     bef = lambda: None
     before(group_name='new')(bef)
     self.assertTrue(bef in t.before)
Ejemplo n.º 12
0
 def test_filter_tests_TestSuite(self):
     clear()
     suite = TestSuite.get_instance()
     suite.get_or_create('gr_name').add_test(Test('a__2', print))
     suite.get_or_create('gr_name').add_test(Test('a__3', print))
     initial_count = suite.tests_count()
     suite.filter_tests('a')
     self.assertEqual(initial_count, suite.tests_count())
Ejemplo n.º 13
0
 def test_check_providers_returns_ok_if_exists(self):
     clear()
     suite = TestSuite.get_instance()
     suite.providers['test'] = print
     test_case = Test('test', inc)
     test_case.provider = 'test'
     suite.get_or_create("group").add_test(test_case)
     r._check_data_providers(suite)
Ejemplo n.º 14
0
 def test_ignored_by_condition_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_ignored_by_condition = inc
     count = COUNT
     test(only_if=lambda: False)(fake)
     r_.start(listener=listener_)
     self.assertEqual(count + 1, COUNT)
Ejemplo n.º 15
0
 def test_before_all_when_before_first(self):
     clear()
     before_ = valid
     before(before_)
     t = Test('first', print)
     list(TestSuite.get_instance().groups.values())[0].add_test(t)
     self.assertTrue(t.before)
     self.assertEqual(before_, t.before[0])
Ejemplo n.º 16
0
 def test_timeout_failed_if_bigger(self):
     clear()
     test(timeout=1)(long)
     start(listener=Listener(0))
     self.assertEqual(1, len(TestSuite.get_instance().broken()))
     self.assertEqual(0, len(TestSuite.get_instance().success()))
     self.assertEqual(0, len(TestSuite.get_instance().failed()))
     self.assertEqual(1, TestSuite.get_instance().tests_count())
Ejemplo n.º 17
0
 def test_ends_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_suite_ends = inc
     count = COUNT
     test(fake)
     r_.start(listener=listener_)
     self.assertEqual(count + 1, COUNT)
Ejemplo n.º 18
0
 def test_timeout_ok_if_less(self):
     clear()
     test(timeout=10)(simple)
     start(listener=Listener(0))
     self.assertEqual(0, len(TestSuite.get_instance().broken()))
     self.assertEqual(1, len(TestSuite.get_instance().success()))
     self.assertEqual(0, len(TestSuite.get_instance().failed()))
     self.assertEqual(1, TestSuite.get_instance().tests_count())
Ejemplo n.º 19
0
 def test_is_run_if_only_true(self):
     clear()
     test(only_if=lambda: True)(sa_ok)
     start(listener=Listener(0))
     self.assertEqual(0, len(TestSuite.get_instance().broken()))
     self.assertEqual(1, len(TestSuite.get_instance().success()))
     self.assertEqual(0, len(TestSuite.get_instance().failed()))
     self.assertEqual(1, TestSuite.get_instance().tests_count())
Ejemplo n.º 20
0
 def test_soft_failed(self):
     clear()
     test(sa_failed)
     start(listener=Listener(0))
     self.assertEqual(0, len(TestSuite.get_instance().broken()))
     self.assertEqual(0, len(TestSuite.get_instance().success()))
     self.assertEqual(1, len(TestSuite.get_instance().failed()))
     self.assertEqual(1, TestSuite.get_instance().tests_count())
Ejemplo n.º 21
0
 def test_dry_run_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_dry_run = inc
     count = COUNT
     test(fake)
     r_.start(listener=listener_, dry_run=True)
     self.assertEqual(count + 1, COUNT)
Ejemplo n.º 22
0
    def test_add_img(self):
        def _():
            add_img("A", b"B")

        clear()
        test(_)
        t = list(TestSuite.get_instance().groups.values())[0].tests[0]
        t.run()
        self.assertEqual({b'B': 'A'}, t.report_params)
Ejemplo n.º 23
0
 def test_provider_get_none(self):
     clear()
     CONTAINER([1, None], name='three')
     test(data_provider="three")(_fn)
     start(listener=Listener(0))
     self.assertEqual(0, len(TestSuite.get_instance().broken()))
     self.assertEqual(1, len(TestSuite.get_instance().success()))
     self.assertEqual(1, len(TestSuite.get_instance().failed()))
     self.assertEqual(2, TestSuite.get_instance().tests_count())
Ejemplo n.º 24
0
 def test_check_providers_returns_failed_if_not_exists(self):
     clear()
     suite = TestSuite.get_instance()
     suite.providers['test'] = print
     test_case = Test('test', inc)
     test_case.provider = 'test2'
     suite.get_or_create("group").add_test(test_case)
     with self.assertRaises(UnknownProviderName):
         r._check_data_providers(suite)
Ejemplo n.º 25
0
 def test_timeout_failed_with_data(self):
     clear()
     provider(name='three')(return2)
     test(timeout=1, data_provider="three")(long_data)
     start(listener=Listener(0))
     self.assertEqual(3, len(TestSuite.get_instance().broken()))
     self.assertEqual(0, len(TestSuite.get_instance().success()))
     self.assertEqual(0, len(TestSuite.get_instance().failed()))
     self.assertEqual(3, TestSuite.get_instance().tests_count())
Ejemplo n.º 26
0
 def test_starts_call(self):
     clear()
     reload(r_)
     listener_ = Listener(0)
     listener_.on_test_starts = inc
     count = COUNT
     test(fake)
     r_.start(listener=listener_)
     self.assertEqual(count + 1, COUNT)
Ejemplo n.º 27
0
 def test_ignored_TestSuite(self):
     clear()
     suite = TestSuite.get_instance()
     self.assertFalse(suite.ignored())
     test_ = Test('any', print)
     test_.status = 'ignored'
     suite.get_or_create('gr_name').test_results.append(test_)
     self.assertTrue(suite.ignored())
     self.assertEqual(test_, suite.ignored()[0])
Ejemplo n.º 28
0
 def test_on_max_fail_not_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_suite_stop_with_max_fail = inc
     count = COUNT
     test(fail)
     test(fail)
     r_.start(listener=listener_, max_fail=3)
     self.assertEqual(count, COUNT)
Ejemplo n.º 29
0
 def test_before_suite_failed_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_before_suite_failed = inc
     count = COUNT
     before_suite(lambda: int('a'))
     test(fake)
     r_.start(listener=listener_)
     self.assertEqual(count + 1, COUNT)
Ejemplo n.º 30
0
 def test_ignored_call(self):
     clear()
     listener_ = Listener(0)
     listener_.on_ignored = inc
     count = COUNT
     test(fake)
     before(lambda: int('a'))
     r_.start(listener=listener_)
     self.assertEqual(count + 1, COUNT)