Ejemplo n.º 1
0
    def __init__(self, name, new_value=None):
        """Create a MonkeyPatch.

        :param name: The fully qualified object name to override.
        :param new_value: A value to set the name to. If set to
            MonkeyPatch.delete the attribute will be deleted.

        During setup the name will be deleted or assigned the requested value,
        and this will be restored in cleanUp.

        When patching methods, the call signature of name should be a subset
        of the parameters which can be used to call new_value.

        For instance.

        >>> class T:
        ...     def method(self, arg1):
        ...         pass
        >>> class N:
        ...     @staticmethod
        ...     def newmethod(arg1):
        ...         pass

        Patching N.newmethod on top of T.method and then calling T().method(1)
        will not work because they do not have compatible call signatures -
        self will be passed to newmethod because the callable (N.newmethod)
        is placed onto T as a regular function. This allows capturing all the
        supplied parameters while still consulting local state in your
        new_value.
        """
        Fixture.__init__(self)
        self.name = name
        self.new_value = new_value
Ejemplo n.º 2
0
    def __init__(self, name, new_value=None):
        """Create a MonkeyPatch.

        :param name: The fully qualified object name to override.
        :param new_value: A value to set the name to. If set to
            MonkeyPatch.delete the attribute will be deleted.

        During setup the name will be deleted or assigned the requested value,
        and this will be restored in cleanUp.

        When patching methods, the call signature of name should be a subset
        of the parameters which can be used to call new_value.

        For instance.

        >>> class T:
        ...     def method(self, arg1):
        ...         pass
        >>> class N:
        ...     @staticmethod
        ...     def newmethod(arg1):
        ...         pass

        Patching N.newmethod on top of T.method and then calling T().method(1)
        will not work because they do not have compatible call signatures -
        self will be passed to newmethod because the callable (N.newmethod)
        is placed onto T as a regular function. This allows capturing all the
        supplied parameters while still consulting local state in your
        new_value.
        """
        Fixture.__init__(self)
        self.name = name
        self.new_value = new_value
Ejemplo n.º 3
0
    def __init__(self, config_fixture):
        """Initialize the LibrarianServerFixture.

        :param config_fixture: The ConfigFixture in use by our tests.
                               In the layered environment, this is
                               BaseLayer.config_fixture.
        """
        Fixture.__init__(self)
        self._pid = None
        # Track whether the fixture has been setup or not.
        self._setup = False
        self.config_fixture = config_fixture
Ejemplo n.º 4
0
    def __init__(self, name, new_value=None):
        """Create a MonkeyPatch.

        :param name: The fully qualified object name to override.
        :param new_value: A value to set the name to. If set to
            MonkeyPatch.delete the attribute will be deleted.

        During setup the name will be deleted or assigned the requested value,
        and this will be restored in cleanUp.
        """
        Fixture.__init__(self)
        self.name = name
        self.new_value = new_value
Ejemplo n.º 5
0
    def __init__(self, name, new_value=None):
        """Create a MonkeyPatch.

        :param name: The fully qualified object name to override.
        :param new_value: A value to set the name to. If set to
            MonkeyPatch.delete the attribute will be deleted.

        During setup the name will be deleted or assigned the requested value,
        and this will be restored in cleanUp.
        """
        Fixture.__init__(self)
        self.name = name
        self.new_value = new_value
 def __init__(self, root):
     Fixture.__init__(self)
     self.root = root