Esempio n. 1
0
    def result(func):
        """Wrap the given function and return the wrapper.

    Args:
      func: The function to wrap.

    Returns:
      A PhaseDescriptor that, when called will invoke the wrapped function,
        passing plugs as keyword args.

    Raises:
      DuplicatePlugError:  If a plug name is declared twice for the
          same function.
    """
        phase_desc = openhtf.PhaseDescriptor.wrap_or_copy(func)
        duplicates = frozenset(p.name
                               for p in phase_desc.plugs) & frozenset(plugs)
        if duplicates:
            raise DuplicatePlugError(
                'Plugs %s required multiple times on phase %s' %
                (duplicates, func))
        phase_desc.plugs.extend([
            openhtf.PhasePlug(name, a_plug, update_kwargs=update_kwargs)
            for name, a_plug in plugs.iteritems()
        ])
        return phase_desc
Esempio n. 2
0
    def result(func):
        """Wrap the given function and return the wrapper.

    Args:
      func: The function to wrap.

    Returns:
      The wrapper to call.  When called, it will invoke the wrapped function,
        passing plugs as keyword args.

    Raises:
      DuplicatePlugError:  If a plug name is declared twice for the
          same function.
    """
        wrapper = openhtf.TestPhaseInfo.WrapOrReturn(func)
        duplicates = frozenset(wrapper.plugs) & frozenset(plugs)
        if duplicates:
            raise DuplicatePlugError(
                'Plugs %s required multiple times on phase %s' %
                (duplicates, func))
        wrapper.plugs.extend([
            openhtf.PhasePlug(name, plug, update_kwargs)
            for name, plug in plugs.iteritems()
        ])
        return wrapper