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='for'), Keyword()]
     suite.tests[0].keywords[0].keywords = [Keyword(type='foritem')]
     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_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
Пример #3
0
 def run(self, kw, name=None):
     handler = self._context.get_handler(name or kw.name)
     handler.init_keyword(self._context.variables)
     result = KeywordResult(kwname=handler.name or '',
                            libname=handler.libname or '',
                            doc=handler.shortdoc,
                            args=kw.args,
                            assign=self._get_assign(kw.assign),
                            timeout=getattr(handler, 'timeout', ''),
                            type=kw.type,
                            status='NOT_RUN',
                            starttime=get_timestamp())
     self._context.start_keyword(result)
     self._warn_if_deprecated(handler.longname, handler.shortdoc)
     try:
         return_value = self._run(handler, kw)
     except ExecutionFailed as err:
         result.status = self._get_status(err)
         self._end(result, error=err)
         raise
     else:
         if not (self._context.dry_run and handler.type == 'library'):
             result.status = 'PASS'
         self._end(result, return_value)
         return return_value
 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
Пример #5
0
 def run(self, kw, name=None):
     result = KeywordResult(name=self._get_name(kw),
                            type=kw.FOR_LOOP_TYPE,
                            starttime=get_timestamp())
     self._context.start_keyword(result)
     error = self._run_with_error_handling(self._validate_and_run, kw)
     result.status = self._get_status(error)
     result.endtime = get_timestamp()
     self._context.end_keyword(result)
     if error:
         raise error
Пример #6
0
 def _run_one_round(self, data, values):
     name = ', '.join(format_assign_message(var, item)
                      for var, item in zip(data.variables, values))
     result = KeywordResult(name=name,
                            type=data.FOR_ITEM_TYPE,
                            starttime=get_timestamp())
     self._context.start_keyword(result)
     for var, value in zip(data.variables, values):
         self._context.variables[var] = value
     runner = KeywordRunner(self._context, self._templated)
     error = self._run_with_error_handling(runner.run_keywords, data.keywords)
     result.status = self._get_status(error)
     result.endtime = get_timestamp()
     self._context.end_keyword(result)
     return error
 def test_keyword_with_values(self):
     kw = Keyword('Name', 'http://doc', ['a1', 'a2'], (), '1 second',
                  'setup', 'PASS', '20111204 19:42:42.000',
                  '20111204 19:42:42.042')
     self._verify_keyword(kw, 1, 'Name',
                          '<a href="http://doc">http://doc</a>', 'a1, a2',
                          '1 second', 1, 0, 42)
 def test_keyword_with_values(self):
     kw = Keyword('KW Name', 'libname', 'http://doc', ('arg1', 'arg2'),
                  ('${v1}', '${v2}'), ('tag1', 'tag2'), '1 second', 'setup',
                  'PASS', '20111204 19:42:42.000', '20111204 19:42:42.042')
     self._verify_keyword(kw, 1, 'KW Name', 'libname',
                          '<a href="http://doc">http://doc</a>',
                          'arg1, arg2', '${v1}, ${v2}', 'tag1, tag2',
                          '1 second', 1, 0, 42)
 def setUp(self):
     self.suite = TestSuite()
     self.suite.keywords = [Keyword(), Keyword()]
     s1 = self.suite.suites.create()
     s1.keywords.create()
     tc = s1.tests.create()
     tc.keywords = [Keyword(), Keyword(), Keyword()]
     s2 = self.suite.suites.create()
     t1 = s2.tests.create()
     t2 = s2.tests.create()
     t1.keywords = [Keyword()]
     t2.keywords = [Keyword(), Keyword()]
 def test_keyword_name(self):
     kw = Keyword('keyword')
     assert_equal(kw.name, 'keyword')
     kw = Keyword('keyword', 'lib')
     assert_equal(kw.name, 'lib.keyword')
     kw.kwname = 'Kekkonen'
     kw.libname = 'Urho'
     assert_equal(kw.name, 'Urho.Kekkonen')
 def test_name_escaping(self):
     kw = Keyword(
         'quote:"',
         'and *url* https://url.com',
         '*"Doc"*',
     )
     self._verify_keyword(kw, 0, 'quote:&quot;',
                          'and *url* https://url.com', '<b>"Doc"</b>')
     test = TestCase(
         'quote:" and *url* https://url.com',
         '*"Doc"*',
     )
     self._verify_test(test, 'quote:&quot; and *url* https://url.com',
                       '<b>"Doc"</b>')
     suite = TestSuite(
         'quote:" and *url* https://url.com',
         '*"Doc"*',
     )
     self._verify_suite(suite, 'quote:&quot; and *url* https://url.com',
                        '<b>"Doc"</b>')
 def test_default_keyword(self):
     self._verify_keyword(Keyword())
 def test_keyword(self):
     self._verify(Keyword())
 def test_keyword_name_cannot_be_set_directly(self):
     assert_raises(AttributeError, setattr, Keyword(), 'name', 'value')