Beispiel #1
0
 def test_structure(self):
     error = self._failing_import('NoneExisting')
     quote = "'" if PY3 else ''
     type = 'Import' if sys.version_info < (3, 6) else 'ModuleNotFound'
     message = ("Importing 'NoneExisting' failed: {type}Error: No module "
                "named {q}NoneExisting{q}".format(q=quote, type=type))
     expected = (message, self._get_traceback(error),
                 self._get_pythonpath(error), self._get_classpath(error))
     assert_equal(unicode(error), '\n'.join(expected).strip())
Beispiel #2
0
 def _block(self, error, start, end=None):
     include = False
     for line in unicode(error).splitlines():
         if line == end:
             return
         if line == start:
             include = True
         if include:
             yield line
Beispiel #3
0
 def _convert_arguments(self):
     return [{
         'name': a.name,
         'type': a.type_repr,
         'default': a.default_repr,
         'kind': a.kind,
         'required': a.required,
         'repr': unicode(a)
     } for a in self.args]
Beispiel #4
0
 def _arg_to_dict(self, arg):
     return {
         'name': arg.name,
         'type': arg.type_repr,
         'default': arg.default_repr,
         'kind': arg.kind,
         'required': arg.required,
         'repr': unicode(arg)
     }
Beispiel #5
0
 def test_string_reprs(self):
     for for_, exp_str, exp_repr in [
         (For(),
          'FOR        IN    ',
          "For(variables=(), flavor='IN', values=())"),
         (For(('${x}',), 'IN RANGE', ('10',)),
          'FOR    ${x}    IN RANGE    10',
          "For(variables=('${x}',), flavor='IN RANGE', values=('10',))"),
         (For(('${x}', '${y}'), 'IN ENUMERATE', ('a', 'b')),
          'FOR    ${x}    ${y}    IN ENUMERATE    a    b',
          "For(variables=('${x}', '${y}'), flavor='IN ENUMERATE', values=('a', 'b'))"),
         (For([u'${\xfc}'], 'IN', [u'f\xf6\xf6']),
          u'FOR    ${\xfc}    IN    f\xf6\xf6',
          u"For(variables=[%r], flavor='IN', values=[%r])" % (u'${\xfc}', u'f\xf6\xf6'))
     ]:
         assert_equal(unicode(for_), exp_str)
         assert_equal(repr(for_), 'robot.model.' + exp_repr)
         if PY2:
             assert_equal(str(for_), unicode(for_).encode('UTF-8'))
Beispiel #6
0
 def test_string_reprs(self):
     for if_, exp_str, exp_repr in [
         (IfBranch(),
          'IF    None',
          "IfBranch(type='IF', condition=None)"),
         (IfBranch(condition='$x > 1'),
          'IF    $x > 1',
          "IfBranch(type='IF', condition='$x > 1')"),
         (IfBranch(ELSE_IF, condition='$x > 2'),
          'ELSE IF    $x > 2',
          "IfBranch(type='ELSE IF', condition='$x > 2')"),
         (IfBranch(ELSE),
          'ELSE',
          "IfBranch(type='ELSE', condition=None)"),
         (IfBranch(condition=u'$x == "\xe4iti"'),
          u'IF    $x == "\xe4iti"',
          u"IfBranch(type='IF', condition=%r)" % u'$x == "\xe4iti"'),
     ]:
         assert_equal(unicode(if_), exp_str)
         assert_equal(repr(if_), 'robot.model.' + exp_repr)
         if PY2:
             assert_equal(str(if_), unicode(if_).encode('UTF-8'))
 def __init__(self,
              tag_pattern,
              name=None,
              critical=True,
              doc='',
              links=None):
     TagStat.__init__(self,
                      name or unicode(tag_pattern),
                      doc,
                      links,
                      critical=critical,
                      non_critical=not critical)
     self.pattern = tag_pattern
Beispiel #8
0
    def test_string_repr(self):

        for token, exp_str, exp_repr in [
            ((Token.ELSE_IF, 'ELSE IF', 6, 4), 'ELSE IF',
             "Token('ELSE IF', 'ELSE IF', 6, 4)"),
            ((Token.KEYWORD, u'Hyv\xe4', 6, 4), u'Hyv\xe4',
             u"Token('KEYWORD', %r, 6, 4)" % u'Hyv\xe4'),
            ((Token.ERROR, 'bad value', 6, 4, 'The error.'), 'bad value',
             "Token('ERROR', 'bad value', 6, 4, 'The error.')")
        ]:
            token = Token(*token)
            assert_equal(unicode(token), exp_str)
            assert_equal(repr(token), exp_repr)
Beispiel #9
0
 def test_string_reprs(self):
     for kw, exp_str, exp_repr in [
         (Keyword(), '', "Keyword(name='', args=(), assign=())"),
         (Keyword('name'), 'name',
          "Keyword(name='name', args=(), assign=())"),
         (Keyword(None), 'None', "Keyword(name=None, args=(), assign=())"),
         (Keyword('Name', args=('a1', 'a2')), 'Name    a1    a2',
          "Keyword(name='Name', args=('a1', 'a2'), assign=())"),
         (Keyword('Name', assign=('${x}', '${y}')), '${x}    ${y}    Name',
          "Keyword(name='Name', args=(), assign=('${x}', '${y}'))"),
         (Keyword('Name', assign=['${x}='],
                  args=['x']), '${x}=    Name    x',
          "Keyword(name='Name', args=['x'], assign=['${x}='])"),
         (Keyword('Name', args=(1, 2, 3)), 'Name    1    2    3',
          "Keyword(name='Name', args=(1, 2, 3), assign=())"),
         (Keyword(assign=[u'${\xe3}'], name=u'\xe4',
                  args=[u'\xe5']), u'${\xe3}    \xe4    \xe5',
          u'Keyword(name=%r, args=[%r], assign=[%r])' %
          (u'\xe4', u'\xe5', u'${\xe3}'))
     ]:
         assert_equal(unicode(kw), exp_str)
         assert_equal(repr(kw), 'robot.model.' + exp_repr)
         if PY2:
             assert_equal(str(kw), unicode(kw).encode('UTF-8'))
 def get_attributes(self, include_label=False, include_elapsed=False,
                    exclude_empty=True, values_as_strings=False,
                    html_escape=False):
     attrs = {'pass': self.passed, 'fail': self.failed}
     attrs.update(self._get_custom_attrs())
     if include_label:
         attrs['label'] = self.name
     if include_elapsed:
         attrs['elapsed'] = elapsed_time_to_string(self.elapsed,
                                                   include_millis=False)
     if exclude_empty:
         attrs = dict((k, v) for k, v in attrs.items() if v not in ('', None))
     if values_as_strings:
         attrs = dict((k, unicode(v if v is not None else ''))
                      for k, v in attrs.items())
     if html_escape:
         attrs = dict((k, self._html_escape(v)) for k, v in attrs.items())
     return attrs
Beispiel #11
0
 def get_attributes(self, include_label=False, include_elapsed=False,
                    exclude_empty=True, values_as_strings=False,
                    html_escape=False):
     attrs = {'pass': self.passed, 'fail': self.failed}
     attrs.update(self._get_custom_attrs())
     if include_label:
         attrs['label'] = self.name
     if include_elapsed:
         attrs['elapsed'] = elapsed_time_to_string(self.elapsed,
                                                   include_millis=False)
     if exclude_empty:
         attrs = dict((k, v) for k, v in attrs.items() if v not in ('', None))
     if values_as_strings:
         attrs = dict((k, unicode(v if v is not None else ''))
                      for k, v in attrs.items())
     if html_escape:
         attrs = dict((k, self._html_escape(v)) for k, v in attrs.items())
     return attrs
Beispiel #12
0
 def _verify(self, expected, positional_or_named=None, **config):
     spec = ArgumentSpec(positional_or_named=positional_or_named, **config)
     assert_equal(unicode(spec), expected)
     assert_equal(bool(spec), bool(expected))
Beispiel #13
0
 def __str__(self):
     return ' NOT '.join(unicode(pattern) for pattern in self).lstrip()
Beispiel #14
0
 def test_unicode(self):
     assert_equal(unicode(Tags()), '[]')
     assert_equal(unicode(Tags(['y', "X'X", 'Y'])), "[X'X, y]")
     assert_equal(unicode(Tags([u'\xe4', 'a'])), u'[a, \xe4]')
 def test_unicode(self):
     assert_equal(unicode(Tags()), '[]')
     assert_equal(unicode(Tags(['y', "X'X", 'Y'])), "[X'X, y]")
     assert_equal(unicode(Tags([u'\xe4', 'a'])), u'[a, \xe4]')
Beispiel #16
0
 def __str__(self):
     parts = list(self.assign) + [self.name] + list(self.args)
     return '    '.join(unicode(p) for p in parts)
Beispiel #17
0
 def __unicode__(self):
     return ' AND '.join(unicode(pattern) for pattern in self)
Beispiel #18
0
 def __unicode__(self):
     return u'[%s]' % ', '.join(unicode(item) for item in self)
Beispiel #19
0
 def _show_keyword(self, kw, show_name=True):
     if show_name:
         self._header(kw.name, underline='-')
     self._data([('Arguments', '[%s]' % unicode(kw.args))])
     self._doc(kw.doc)
 def _verify_string_representation(self, source, expected):
     assert_equal(unicode(source), expected)
     assert_equal(u'-%s-' % source, '-%s-' % expected)
 def __init__(self, tag_pattern, name=None, critical=True, doc='',
              links=None):
     TagStat.__init__(self, name or unicode(tag_pattern), doc, links,
                      critical=critical, non_critical=not critical)
     self.pattern = tag_pattern
Beispiel #22
0
 def __unicode__(self):
     return u'[%s]' % u', '.join(unicode(pattern) for pattern in self)
Beispiel #23
0
 def __unicode__(self):
     return ' NOT '.join(unicode(pattern) for pattern in self).lstrip()
Beispiel #24
0
 def __unicode__(self):
     return ' OR '.join(unicode(pattern) for pattern in self)
 def _verify_string_representation(self, source, expected):
     assert_equal(unicode(source), expected)
     assert_equal(u'-%s-' % source, '-%s-' % expected)
 def test_str(self):
     for tc, expected in [(self.empty, ''), (self.ascii, 'Kekkonen'),
                          (self.non_ascii, u'hyv\xe4 nimi')]:
         assert_equal(unicode(tc), expected)
         if PY2:
             assert_equal(str(tc), unicode(tc).encode('UTF-8'))
 def test_unicode(self):
     assert_equal(unicode(self.empty), '')
     assert_equal(unicode(self.ascii), 'Kekkonen')
     assert_equal(unicode(self.non_ascii), u'hyv\xe4 nimi')
Beispiel #28
0
 def __unicode__(self):
     return unicode(self.value or '')
Beispiel #29
0
 def from_Enum(cls, enum_type):
     return cls(name=enum_type.__name__,
                doc=getdoc(enum_type) or '',
                members=[{'name': name, 'value': unicode(member.value)}
                         for name, member in enum_type.__members__.items()])
 def test_unicode(self):
     assert_equal(unicode(ItemList(int, items=[1, 2, 3, 4])),
                  '[1, 2, 3, 4]')
     assert_equal(unicode(ItemList(unicode, items=[u'hyv\xe4\xe4', u'y\xf6'])),
                  u'[hyv\xe4\xe4, y\xf6]')
Beispiel #31
0
 def __unicode__(self):
     return unicode(self.value or '')
 def test_unicode(self):
     pattern = u'\xe4 OR \xe5 NOT \xe6 AND \u2603 OR ??'
     expected = '[%s]' % pattern
     assert_equal(unicode(TagPatterns(pattern)), expected)
     assert_equal(unicode(TagPatterns(pattern.replace(' ', ''))), expected)
 def __repr__(self):
     return repr(unicode(self))
 def test_unicode(self):
     assert_equal(unicode(ItemList(int, items=[1, 2, 3, 4])),
                  '[1, 2, 3, 4]')
     assert_equal(
         unicode(ItemList(unicode, items=[u'hyv\xe4\xe4', u'y\xf6'])),
         unicode([u'hyv\xe4\xe4', u'y\xf6']))
Beispiel #35
0
 def _get_critical_stat(self, pattern, critical):
     name = unicode(pattern)
     return CriticalTagStat(pattern, name, critical, self.get_doc(name),
                            self.get_links(name))
Beispiel #36
0
 def get_repr_from_json_arg_model(self, model):
     return unicode(
         ArgInfo(kind=model['kind'],
                 name=model['name'],
                 types=tuple(model['types']),
                 default=model['default'] or ArgInfo.NOTSET))
 def __unicode__(self):
     return ', '.join(unicode(arg) for arg in self)
Beispiel #38
0
 def __str__(self):
     return u'[%s]' % u', '.join(unicode(pattern) for pattern in self)
Beispiel #39
0
 def test_unicode(self):
     pattern = u'\xe4 OR \xe5 NOT \xe6 AND \u2603 OR ??'
     expected = '[%s]' % pattern
     assert_equal(unicode(TagPatterns(pattern)), expected)
     assert_equal(unicode(TagPatterns(pattern.replace(' ', ''))), expected)
Beispiel #40
0
 def __str__(self):
     return ' OR '.join(unicode(pattern) for pattern in self)
Beispiel #41
0
 def test_unicode(self):
     assert_equal(unicode(self.empty), '')
     assert_equal(unicode(self.ascii), 'Kekkonen')
     assert_equal(unicode(self.non_ascii), u'hyv\xe4 nimi')
 def __unicode__(self):
     return u'[%s]' % ', '.join(unicode(item) for item in self)