Esempio n. 1
0
 def __call__(self, *args, **kwargs):
     """ if passed a single callable argument: decorate it with mark info.
         otherwise add *args/**kwargs in-place to mark information. """
     from _pytest.mark import Mark, MarkInfo
     if args:
         func = args[0]
         if len(args) == 1 and hasattr(func, '__call__') or \
                 hasattr(func, '__bases__'):
             if hasattr(func, '__bases__'):
                 if hasattr(func, 'pytestmark'):
                     markers = func.pytestmark
                     if not isinstance(markers, list):
                         func.pytestmark = [markers, self]
                     else:
                         markers.append(self)
                 else:
                     func.pytestmark = [self]
             else:
                 for x in self.tickets_id:
                     name = '%s%s' % (self.PREFIX, x)
                     holder = getattr(func, name, None)
                     mark = Mark(name, self.args, self.kwargs)
                     if holder is None:
                         holder = MarkInfo(mark)
                         setattr(func, name, holder)
                     else:
                         holder.add_mark(mark)
             return func
     kw = self.kwargs.copy()
     kw.update(kwargs)
     args = self.args + args
     return self.__class__(self.markname, args=args, kwargs=kw)
Esempio n. 2
0
 def test_markinfo_repr(self):
     from _pytest.mark import MarkInfo, Mark
     m = MarkInfo.for_mark(Mark("hello", (1, 2), {}))
     repr(m)
Esempio n. 3
0
 def test_markinfo_repr(self):
     from _pytest.mark import MarkInfo
     m = MarkInfo("hello", (1,2), {})
     repr(m)
Esempio n. 4
0
    def test_markinfo_repr(self):
        from _pytest.mark import MarkInfo, Mark

        m = MarkInfo.for_mark(Mark("hello", (1, 2), {}))
        repr(m)