def _get_suite_with_tests(self):
     suite = TestSuite(name='suite')
     suite.tests = [TestCase('t1'), TestCase('t2')]
     suite.tests[0].keywords = [Keyword('t1-k1'), Keyword('t1-k2')]
     suite.tests[0].keywords[0].keywords = [Keyword('t1-k1-k1')]
     suite.tests[1].keywords = [Keyword('t2-k1')]
     return suite
Beispiel #2
0
 def start_suite(self, suite):
     variables = GLOBAL_VARIABLES.copy()
     variables.set_from_variable_table(suite.variables)
     result = TestSuite(source=suite.source,
                        name=suite.name,
                        doc=suite.doc,
                        metadata=suite.metadata,
                        starttime=get_timestamp())
     if not self.result:
         result.set_criticality(self._settings.critical_tags,
                                self._settings.non_critical_tags)
         self.result = Result(root_suite=result)
         self.result.configure(status_rc=self._settings.status_rc,
                               stat_config=self._settings.statistics_config)
     else:
         self._suite.suites.append(result)
     ns = Namespace(result, variables, self._variables,
                    suite.user_keywords, suite.imports)
     EXECUTION_CONTEXTS.start_suite(ns, self._output, self._settings.dry_run)
     self._context.set_suite_variables(result)
     if not (self._suite_status and self._suite_status.failures):
         ns.handle_imports()
     variables.resolve_delayed()
     result.doc = self._resolve_setting(result.doc)
     result.metadata = [(self._resolve_setting(n), self._resolve_setting(v))
                        for n, v in result.metadata.items()]
     self._context.set_suite_variables(result)
     self._suite = result
     self._suite_status = SuiteStatus(self._suite_status,
                                      self._settings.exit_on_failure,
                                      self._settings.skip_teardown_on_exit)
     self._output.start_suite(ModelCombiner(suite, self._suite))
     self._run_setup(suite.keywords.setup, self._suite_status)
     self._executed_tests = NormalizedDict(ignore='_')
 def test_criticality_set_for_child_suites_earlier_is_ignored(self):
     self.suite.set_criticality('use', 'us')
     sub2 = TestSuite()
     sub2.set_criticality('ignore', 'these')
     self.suite.suites.append(sub2)
     self._verify_criticality(self.suite, ['use'], ['us'])
     self._verify_criticality(self.sub, ['use'], ['us'])
     self._verify_criticality(sub2, ['use'], ['us'])
 def test_passed(self):
     suite = TestSuite()
     assert_true(suite.passed)
     suite.tests.create(status='PASS')
     assert_true(suite.passed)
     suite.tests.create(status='FAIL', tags='tag')
     assert_false(suite.passed)
     suite.set_criticality(non_critical_tags='tag')
     assert_true(suite.passed)
 def _create_suite_with_tests(self):
     suite = TestSuite()
     suite.set_criticality([], ['nc'])
     suite.tests = [TestCase(status='PASS'),
                    TestCase(status='PASS', tags='nc'),
                    TestCase(status='PASS'),
                    TestCase(status='FAIL'),
                    TestCase(status='FAIL', tags='nc')]
     return suite
 def test_remove_passed_does_now_remove_setup_and_teardown_from_suite_with_noncritical_failure(self):
     suite = TestSuite()
     suite.set_criticality([], ['non'])
     suite.keywords.create(type=SETUP).messages.create(message='some')
     suite.keywords.create(type=TEARDOWN).keywords.create()
     suite.tests.create(status='FAIL', tags='non')
     assert_equal(suite.status, 'PASS')
     self._remove_passed(suite)
     assert_equal(len(suite.keywords.setup.messages), 1)
     assert_equal(len(suite.keywords.teardown.keywords), 1)
 def test_suite_stats_when_suite_has_no_times(self):
     suite = TestSuite()
     assert_equal(Statistics(suite).suite.stat.elapsed, 0)
     ts = '20120816 00:00:'
     suite.tests = [TestCase(starttime=ts+'00.000', endtime=ts+'00.001'),
                    TestCase(starttime=ts+'00.001', endtime=ts+'01.001')]
     assert_equal(Statistics(suite).suite.stat.elapsed, 1001)
     suite.suites = [TestSuite(starttime=ts+'02.000', endtime=ts+'12.000'),
                     TestSuite()]
     assert_equal(Statistics(suite).suite.stat.elapsed, 11001)
class TestTestAttributes(unittest.TestCase):

    def setUp(self):
        self.suite = TestSuite()
        self.suite.tests = [TestCase()]
        self.suite.suites = [TestSuite()]
        self.suite.suites[0].tests = [TestCase(tags=['tag'])]

    def test_set_tags(self):
        self.suite.visit(SuiteConfigurer(set_tags=['new']))
        assert_equal(list(self.suite.tests[0].tags), ['new'])
        assert_equal(list(self.suite.suites[0].tests[0].tags), ['new', 'tag'])

    def test_tags_are_normalized(self):
        self.suite.visit(SuiteConfigurer(set_tags=['TAG', '', 't a g', 'NONE']))
        assert_equal(list(self.suite.tests[0].tags), ['TAG'])
        assert_equal(list(self.suite.suites[0].tests[0].tags), ['tag'])

    def test_remove_negative_tags(self):
        self.suite.visit(SuiteConfigurer(set_tags=['n', '-TAG']))
        assert_equal(list(self.suite.tests[0].tags), ['n'])
        assert_equal(list(self.suite.suites[0].tests[0].tags), ['n'])

    def test_remove_negative_tags_using_pattern(self):
        self.suite.visit(SuiteConfigurer(set_tags=['-t*', '-nomatch']))
        assert_equal(list(self.suite.tests[0].tags), [])
        assert_equal(list(self.suite.suites[0].tests[0].tags), [])
 def setUp(self):
     ts = '20120816 00:00:'
     suite = TestSuite(starttime=ts+'00.000', endtime=ts+'59.999')
     suite.suites = [
         TestSuite(starttime=ts+'00.000', endtime=ts+'30.000'),
         TestSuite(starttime=ts+'30.000', endtime=ts+'42.042')
     ]
     suite.suites[0].tests = [
         TestCase(starttime=ts+'00.000', endtime=ts+'00.001', tags=['t1']),
         TestCase(starttime=ts+'00.001', endtime=ts+'01.001', tags=['t1', 't2'])
     ]
     suite.suites[1].tests = [
         TestCase(starttime=ts+'30.000', endtime=ts+'40.000', tags=['t1', 't2', 't3'])
     ]
     suite.set_criticality(critical_tags=['t2'])
     self.stats = Statistics(suite, tag_stat_combine=[('?2', 'combined')])
def generate_suite():
    suite = TestSuite(name='Root Suite')
    suite.set_criticality(critical_tags=['smoke'])
    s1 = suite.suites.create(name='First Sub Suite')
    s2 = suite.suites.create(name='Second Sub Suite')
    s11 = s1.suites.create(name='Sub Suite 1_1')
    s12 = s1.suites.create(name='Sub Suite 1_2')
    s13 = s1.suites.create(name='Sub Suite 1_3')
    s21 = s2.suites.create(name='Sub Suite 2_1')
    s11.tests = [TestCase(status='PASS'), TestCase(status='FAIL', tags=['t1'])]
    s12.tests = [TestCase(status='PASS', tags=['t_1','t2',]),
                 TestCase(status='PASS', tags=['t1','smoke']),
                 TestCase(status='FAIL', tags=['t1','t2','t3','smoke'])]
    s13.tests = [TestCase(status='PASS', tags=['t1','t 2','smoke'])]
    s21.tests = [TestCase(status='FAIL', tags=['t3','Smoke'])]
    return suite
Beispiel #11
0
    def start_suite(self, suite):
        with open('Excute.txt', 'w') as f:
            f.write('TS=')
            f.write(str(suite.name))
            f.write('\n')

        self._output.library_listeners.new_suite_scope()
        result = TestSuite(source=suite.source,
                           name=suite.name,
                           doc=suite.doc,
                           metadata=suite.metadata,
                           starttime=get_timestamp())
        if not self.result:
            result.set_criticality(self._settings.critical_tags,
                                   self._settings.non_critical_tags)
            self.result = Result(root_suite=result)
            self.result.configure(status_rc=self._settings.status_rc,
                                  stat_config=self._settings.statistics_config)
        else:
            self._suite.suites.append(result)
        self._suite = result
        self._suite_status = SuiteStatus(self._suite_status,
                                         self._settings.exit_on_failure,
                                         self._settings.exit_on_error,
                                         self._settings.skip_teardown_on_exit)
        ns = Namespace(self._variables, result, suite.resource)
        ns.start_suite()
        ns.variables.set_from_variable_table(suite.resource.variables)
        EXECUTION_CONTEXTS.start_suite(result, ns, self._output,
                                       self._settings.dry_run)
        self._context.set_suite_variables(result)
        if not self._suite_status.failures:
            ns.handle_imports()
            ns.variables.resolve_delayed()
        result.doc = self._resolve_setting(result.doc)
        result.metadata = [(self._resolve_setting(n), self._resolve_setting(v))
                           for n, v in result.metadata.items()]
        self._context.set_suite_variables(result)
        self._output.start_suite(ModelCombiner(suite, result,
                                               tests=suite.tests,
                                               suites=suite.suites,
                                               test_count=suite.test_count))
        self._output.register_error_listener(self._suite_status.error_occurred)
        self._run_setup(suite.keywords.setup, self._suite_status)
        self._executed_tests = NormalizedDict(ignore='_')
class TestCriticality(unittest.TestCase):

    def setUp(self):
        self.suite = TestSuite()
        self.sub = self.suite.suites.create()

    def test_default_criticality(self):
        self._verify_criticality(self.suite, [], [])
        self._verify_criticality(self.sub, [], [])

    def test_set_criticality(self):
        self.suite.set_criticality(['c1', 'c2'], 'non')
        self._verify_criticality(self.suite, ['c1', 'c2'], ['non'])
        self._verify_criticality(self.sub, ['c1', 'c2'], ['non'])

    def test_cannot_set_criticality_for_child_suites(self):
        assert_raises(TypeError, self.sub.set_criticality)

    def test_criticality_set_for_child_suites_earlier_is_ignored(self):
        self.suite.set_criticality('use', 'us')
        sub2 = TestSuite()
        sub2.set_criticality('ignore', 'these')
        self.suite.suites.append(sub2)
        self._verify_criticality(self.suite, ['use'], ['us'])
        self._verify_criticality(self.sub, ['use'], ['us'])
        self._verify_criticality(sub2, ['use'], ['us'])

    def test_critical_with_parent(self):
        suite = TestSuite()
        assert_equal(suite.tests.create().critical, True)
        suite.set_criticality(critical_tags=['crit'])
        assert_equal(suite.tests.create().critical, False)
        assert_equal(suite.tests.create(tags=['crit']).critical, True)

    def test_critical_without_parent(self):
        assert_equal(TestCase().critical, True)

    def _verify_criticality(self, suite, crit, non_crit):
        assert_equal([str(t) for t in suite.criticality.critical_tags], crit)
        assert_equal([str(t) for t in suite.criticality.non_critical_tags], non_crit)
 def test_nested_structure(self):
     suite = TestSuite()
     suite.set_criticality(critical_tags=['crit'])
     suite.keywords = [Keyword(type='setup'), Keyword(type='teardown')]
     K1 = self._verify_keyword(suite.keywords[0], type=1)
     K2 = self._verify_keyword(suite.keywords[1], type=2)
     suite.suites = [TestSuite()]
     suite.suites[0].tests = [TestCase(tags=['crit', 'xxx'])]
     t = self._verify_test(suite.suites[0].tests[0], tags=('crit', 'xxx'))
     suite.tests = [TestCase(), TestCase(status='PASS')]
     S1 = self._verify_suite(suite.suites[0],
                             status=0, tests=(t,), stats=(1, 0, 1, 0))
     suite.tests[0].keywords = [Keyword(type=Keyword.FOR_LOOP_TYPE), Keyword()]
     suite.tests[0].keywords[0].keywords = [Keyword(type=Keyword.FOR_ITEM_TYPE)]
     suite.tests[0].keywords[0].messages = [Message()]
     k = self._verify_keyword(suite.tests[0].keywords[0].keywords[0], type=4)
     m = self._verify_message(suite.tests[0].keywords[0].messages[0])
     k1 = self._verify_keyword(suite.tests[0].keywords[0],
                               type=3, keywords=(k,), messages=(m,))
     suite.tests[0].keywords[1].messages = [Message(), Message('msg', level='TRACE')]
     m1 = self._verify_message(suite.tests[0].keywords[1].messages[0])
     m2 = self._verify_message(suite.tests[0].keywords[1].messages[1], 'msg', level=0)
     k2 = self._verify_keyword(suite.tests[0].keywords[1], messages=(m1, m2))
     T1 = self._verify_test(suite.tests[0], critical=0, keywords=(k1, k2))
     T2 = self._verify_test(suite.tests[1], critical=0, status=1)
     self._verify_suite(suite, status=0, keywords=(K1, K2), suites=(S1,),
                        tests=(T1, T2), stats=(3, 1, 1, 0))
     self._verify_min_message_level('TRACE')
 def _get_suite(self):
     ts = lambda s, ms=0: '20120816 16:09:%02d.%03d' % (s, ms)
     suite = TestSuite(name='root', starttime=ts(0), endtime=ts(42))
     suite.set_criticality(critical_tags=['t2'])
     sub1 = TestSuite(name='sub1', starttime=ts(0), endtime=ts(10))
     sub2 = TestSuite(name='sub2')
     suite.suites = [sub1, sub2]
     sub1.tests = [
         TestCase(tags=['t1', 't2'], status='PASS', starttime=ts(0), endtime=ts(1, 500)),
         TestCase(tags=['t1', 't3'], status='FAIL', starttime=ts(2), endtime=ts(3, 499))
     ]
     sub2.tests = [
         TestCase(tags=['t1', 't2'], status='PASS', starttime=ts(10), endtime=ts(30))
     ]
     sub2.suites.create(name='below suite stat level')\
             .tests.create(tags=['t1'], status='FAIL', starttime=ts(30), endtime=ts(40))
     return suite
 def test_deeper_level(self):
     PASS = TestCase(status='PASS')
     FAIL = TestCase(status='FAIL')
     suite = TestSuite(name='1')
     suite.suites = [TestSuite(name='1'), TestSuite(name='2'), TestSuite(name='3')]
     suite.suites[0].suites = [TestSuite(name='1')]
     suite.suites[1].suites = [TestSuite(name='1'), TestSuite(name='2')]
     suite.suites[2].tests = [PASS, FAIL]
     suite.suites[0].suites[0].suites = [TestSuite(name='1')]
     suite.suites[1].suites[0].tests = [PASS, PASS, PASS, FAIL]
     suite.suites[1].suites[1].tests = [PASS, PASS, FAIL, FAIL]
     suite.suites[0].suites[0].suites[0].tests = [FAIL, FAIL, FAIL]
     s1 = Statistics(suite, suite_stat_level=3).suite
     verify_suite(s1, '1', 's1', 6, 7)
     [s11, s12, s13] = s1.suites
     verify_suite(s11, '1.1', 's1-s1', 0, 3)
     verify_suite(s12, '1.2', 's1-s2', 5, 3)
     verify_suite(s13, '1.3', 's1-s3', 1, 1)
     [s111] = s11.suites
     verify_suite(s111, '1.1.1', 's1-s1-s1', 0, 3)
     [s121, s122] = s12.suites
     verify_suite(s121, '1.2.1', 's1-s2-s1', 3, 1)
     verify_suite(s122, '1.2.2', 's1-s2-s2', 2, 2)
     assert_equal(len(s111.suites), 0)
class TestFiltering(unittest.TestCase):

    def setUp(self):
        self.suite = TestSuite(name='root')
        self.suite.tests = [TestCase(name='n0'), TestCase(name='n1', tags=['t1']),
                            TestCase(name='n2', tags=['t1', 't2'])]
        self.suite.suites.create(name='sub').tests.create(name='n1', tags=['t1'])

    def test_include(self):
        self.suite.visit(SuiteConfigurer(include_tags=['t1', 'none', '', '?2']))
        assert_equal([t.name for t in self.suite.tests], ['n1', 'n2'])
        assert_equal([t.name for t in self.suite.suites[0].tests], ['n1'])

    def test_exclude(self):
        self.suite.visit(SuiteConfigurer(exclude_tags=['t1', '?1ANDt2']))
        assert_equal([t.name for t in self.suite.tests], ['n0'])
        assert_equal(list(self.suite.suites), [])

    def test_include_by_names(self):
        self.suite.visit(SuiteConfigurer(include_suites=['s?b', 'xxx'],
                                         include_tests=['', '*1', 'xxx']))
        assert_equal(list(self.suite.tests), [])
        assert_equal([t.name for t in self.suite.suites[0].tests], ['n1'])

    def test_no_matching_tests_with_one_selector_each(self):
        configurer = SuiteConfigurer(include_tags='i', exclude_tags='e',
                                     include_suites='s', include_tests='t')
        assert_raises_with_msg(DataError,
                               "Suite 'root' contains no tests with tag 'i', "
                               "without tag 'e' and named 't' in suite 's'.",
                               self.suite.visit, configurer)

    def test_no_matching_tests_with_multiple_selectors(self):
        configurer = SuiteConfigurer(include_tags=['i1', 'i2'],
                                     exclude_tags=['e1', 'e2'],
                                     include_suites=['s1', 's2', 's3'],
                                     include_tests=['t1', 't2'])
        assert_raises_with_msg(DataError,
                               "Suite 'root' contains no tests "
                               "with tags 'i1' or 'i2', "
                               "without tags 'e1' or 'e2' and "
                               "named 't1' or 't2' "
                               "in suites 's1', 's2' or 's3'.",
                               self.suite.visit, configurer)

    def test_empty_suite(self):
        suite = TestSuite(name='x')
        suite.visit(SuiteConfigurer(empty_suite_ok=True))
        assert_raises_with_msg(DataError,
                               "Suite 'x' contains no tests.",
                               suite.visit, SuiteConfigurer())
class TestSuiteAttributes(unittest.TestCase):

    def setUp(self):
        self.suite = TestSuite(name='Suite', metadata={'A A': '1', 'bb': '1'})
        self.suite.tests.create(name='Make suite non-empty')

    def test_name_and_doc(self):
        self.suite.visit(SuiteConfigurer(name='New Name', doc='New Doc'))
        assert_equal(self.suite.name, 'New Name')
        assert_equal(self.suite.doc, 'New Doc')

    def test_metadata(self):
        self.suite.visit(SuiteConfigurer(metadata={'bb': '2', 'C': '2'}))
        assert_equal(self.suite.metadata, {'A A': '1', 'bb': '2', 'C': '2'})

    def test_metadata_is_normalized(self):
        self.suite.visit(SuiteConfigurer(metadata={'aa': '2', 'B_B': '2'}))
        assert_equal(self.suite.metadata, {'A A': '2', 'bb': '2'})
Beispiel #18
0
 def test_suite_status_is_passed_if_only_passed_tests(self):
     suite = TestSuite()
     for i in range(10):
         suite.tests.create(status='PASS')
     assert_equal(TestSuite().status, 'PASS')
Beispiel #19
0
 def test_suite_passed(self):
     suite = TestSuite()
     assert_equal(suite.passed, True)
     suite.tests.create(status='FAIL')
     assert_equal(suite.passed, False)
     assert_raises(AttributeError, setattr, TestSuite(), 'passed', True)
Beispiel #20
0
 def setUp(self):
     self.suite = TestSuite()
     self.sub = self.suite.suites.create()
Beispiel #21
0
 def test_suite_status_is_skip_if_only_skipped_tests(self):
     suite = TestSuite()
     for i in range(10):
         suite.tests.create(status='SKIP')
     assert_equal(suite.status, 'SKIP')
     assert_true(suite.skipped)
Beispiel #22
0
 def test_suite_status_is_skip_if_there_are_no_tests(self):
     assert_equal(TestSuite().status, 'SKIP')
 def test_critical_with_parent(self):
     suite = TestSuite()
     assert_equal(suite.tests.create().critical, True)
     suite.set_criticality(critical_tags=['crit'])
     assert_equal(suite.tests.create().critical, False)
     assert_equal(suite.tests.create(tags=['crit']).critical, True)
 def setUp(self):
     suite = TestSuite(name='Hello')
     suite.tests = [TestCase(status='PASS'), TestCase(status='PASS'),
                    TestCase(status='FAIL')]
     self.statistics = Statistics(suite)
 def test_empty_suite(self):
     suite = TestSuite(name='x')
     suite.visit(SuiteConfigurer(empty_suite_ok=True))
     assert_raises_with_msg(DataError,
                            "Suite 'x' contains no tests.",
                            suite.visit, SuiteConfigurer())
 def setUp(self):
     self.suite = TestSuite(name='Suite', metadata={'A A': '1', 'bb': '1'})
     self.suite.tests.create(name='Make suite non-empty')
 def _get_suite_with_keywords(self):
     suite = TestSuite(name='root')
     suite.setup.config(kwname='k1')
     suite.teardown.config(kwname='k2')
     suite.setup.body.create_keyword('k1-k2')
     return suite
 def setUp(self):
     self.suite = TestSuite(name='root')
     self.suite.tests = [TestCase(name='n0'), TestCase(name='n1', tags=['t1']),
                         TestCase(name='n2', tags=['t1', 't2'])]
     self.suite.suites.create(name='sub').tests.create(name='n1', tags=['t1'])
Beispiel #29
0
 def test_suite_status_cannot_be_set_directly(self):
     suite = TestSuite()
     for attr in 'status', 'passed', 'failed', 'skipped':
         assert_true(hasattr(suite, attr))
         assert_raises(AttributeError, setattr, suite, attr, True)
Beispiel #30
0
 def setUp(self):
     suite = TestSuite(name='Hello')
     suite.tests = [TestCase(status='PASS'), TestCase(status='PASS'),
                    TestCase(status='FAIL'), TestCase(status='SKIP')]
     self.statistics = Statistics(suite)
Beispiel #31
0
 def test_suite_elapsed_time_is_zero_by_default(self):
     suite = TestSuite()
     assert_equal(suite.elapsedtime, 0)
 def _get_suite(self):
     ts = lambda s, ms=0: '20120816 16:09:%02d.%03d' % (s, ms)
     suite = TestSuite(name='root', starttime=ts(0), endtime=ts(42))
     suite.set_criticality(critical_tags=['t2'])
     sub1 = TestSuite(name='sub1', starttime=ts(0), endtime=ts(10))
     sub2 = TestSuite(name='sub2')
     suite.suites = [sub1, sub2]
     sub1.tests = [
         TestCase(tags=['t1', 't2'],
                  status='PASS',
                  starttime=ts(0),
                  endtime=ts(1, 500)),
         TestCase(tags=['t1', 't3'],
                  status='FAIL',
                  starttime=ts(2),
                  endtime=ts(3, 499))
     ]
     sub2.tests = [
         TestCase(tags=['t1', 't2'],
                  status='PASS',
                  starttime=ts(10),
                  endtime=ts(30))
     ]
     sub2.suites.create(name='below suite stat level')\
             .tests.create(tags=['t1'], status='FAIL', starttime=ts(30), endtime=ts(40))
     return suite
 def _get_suite_with_keywords(self):
     suite = TestSuite(name='root')
     suite.keywords = [Keyword('k1', type='setup'), Keyword('k2', type='teardown')]
     suite.keywords[0].keywords = [Keyword('k1-k2')]
     return suite
Beispiel #34
0
 def setUp(self):
     self.suite = TestSuite(name='root')
     self.suite.tests = [TestCase(name='n0'), TestCase(name='n1', tags=['t1']),
                         TestCase(name='n2', tags=['t1', 't2'])]
     self.suite.suites.create(name='sub').tests.create(name='n1', tags=['t1'])
Beispiel #35
0
 def _create_nested_suite_with_tests(self):
     suite = TestSuite()
     suite.suites = [self._create_suite_with_tests(),
                     self._create_suite_with_tests()]
     return suite
Beispiel #36
0
 def test_empty_suite(self):
     suite = TestSuite(name='x')
     suite.visit(SuiteConfigurer(empty_suite_ok=True))
     assert_raises_with_msg(DataError, "Suite 'x' contains no tests.",
                            suite.visit, SuiteConfigurer())
Beispiel #37
0
 def test_suite_status_is_pass_if_passed_and_skipped(self):
     suite = TestSuite()
     for i in range(5):
         suite.tests.create(status='PASS')
         suite.tests.create(status='SKIP')
     assert_equal(suite.status, 'PASS')
 def test_suite_elapsed_time_when_start_and_end_given(self):
     suite = TestSuite()
     suite.starttime = '20010101 10:00:00.000'
     suite.endtime = '20010101 10:00:01.234'
     assert_equal(suite.elapsedtime, 1234)
Beispiel #39
0
 def test_testsuite(self):
     self._verify(TestSuite())
 def _create_nested_suite_with_tests(self):
     suite = TestSuite()
     suite.set_criticality([], ['nc'])
     suite.suites = [self._create_suite_with_tests(),
                     self._create_suite_with_tests()]
     return suite
Beispiel #41
0
 def test_critical_with_parent(self):
     suite = TestSuite()
     assert_equal(suite.tests.create().critical, True)
     suite.set_criticality(critical_tags=['crit'])
     assert_equal(suite.tests.create().critical, False)
     assert_equal(suite.tests.create(tags=['crit']).critical, True)
Beispiel #42
0
 def setUp(self):
     self.suite = TestSuite()
     self.suite.tests = [TestCase()]
     self.suite.suites = [TestSuite()]
     self.suite.suites[0].tests = [TestCase(tags=['tag'])]
Beispiel #43
0
 def test_suite_status_is_passed_by_default(self):
     assert_equal(TestSuite().status, 'PASS')
Beispiel #44
0
 def _get_suite_with_keywords(self):
     suite = TestSuite(name='root')
     suite.setup.config(kwname='k1', type='setup')
     suite.teardown.config(kwname='k2', type='teardown')
     suite.setup.keywords.create('k1-k2')
     return suite
Beispiel #45
0
 def test_suite_status_is_failed_if_failed_subsuite(self):
     suite = TestSuite()
     suite.suites.create().tests.create(status='FAIL')
     assert_equal(suite.status, 'FAIL')
Beispiel #46
0
 def test_default_suite(self):
     self._verify_suite(TestSuite())
Beispiel #47
0
 def test_suite_elapsed_time_when_start_and_end_given(self):
     suite = TestSuite()
     suite.starttime = '20010101 10:00:00.000'
     suite.endtime = '20010101 10:00:01.234'
     assert_equal(suite.elapsedtime, 1234)
Beispiel #48
0
 def test_suite_with_values(self):
     suite = TestSuite('Name', 'Doc', {'m1': 'v1', 'M2': 'V2'}, None, 'Message',
                       '20111204 19:00:00.000', '20111204 19:00:42.001')
     self._verify_suite(suite, 'Name', 'Doc', ('m1', '<p>v1</p>', 'M2', '<p>V2</p>'),
                        message='Message', start=0, elapsed=42001)
Beispiel #49
0
 def _test_suite_elapsed_time_is_test_time(self):
     suite = TestSuite()
     suite.tests.create(starttime='19991212 12:00:00.010',
                        endtime='19991212 13:00:01.010')
     assert_equal(suite.elapsedtime, 3610000)
Beispiel #50
0
 def test_relative_source(self):
     self._verify_suite(TestSuite(source='non-existing'), source='non-existing')
     source = join(CURDIR, 'test_jsmodelbuilders.py')
     self._verify_suite(TestSuite(source=source), source=source,
                        relsource=basename(source))
 def setUp(self):
     self.suite = TestSuite()
     self.sub = self.suite.suites.create()
Beispiel #52
0
 def test_suite_html_formatting(self):
     self._verify_suite(TestSuite(name='*xxx*', doc='*bold* <&>',
                                  metadata={'*x*': '*b*', '<': '>'}),
                        name='*xxx*', doc='<b>bold</b> &lt;&amp;&gt;',
                        metadata=('*x*', '<p><b>b</b></p>', '&lt;', '<p>&gt;</p>'))
Beispiel #53
0
 def setUp(self):
     self.suite = TestSuite(name='Suite', metadata={'A A': '1', 'bb': '1'})
     self.suite.tests.create(name='Make suite non-empty')
 def setUp(self):
     self.suite = TestSuite()
     self.suite.tests = [TestCase()]
     self.suite.suites = [TestSuite()]
     self.suite.suites[0].tests = [TestCase(tags=['tag'])]
Beispiel #55
0
 def test_remove_passed_does_not_remove_when_test_contains_warning(self):
     suite = TestSuite()
     test = self._test_with_warning(suite)
     self._remove_passed(suite)
     assert_equal(len(test.body[0].body), 1)
     assert_equal(len(test.body[1].messages), 1)
Beispiel #56
0
 def __init__(self, statistics=None, **kwargs):
     TestSuite.__init__(self, **kwargs)
     self._statistics = statistics