### Navigation

- index
- modules
- Home »
- Contents »
- Module code »

# Source code for safe.storage.utilities_test

    """**Utilities to to support test suite**
    """

    import types

    def _same_API(X, Y, exclude=None):
        """Check that public methods of X also exist in Y
        """

        if exclude is None:
            exclude = []

        for name in dir(X):

            # Skip internal symbols
            if name.startswith('_'):
                continue

            # Skip explicitly excluded methods
            if name in exclude:
                continue

            # Check membership of methods
            attr = getattr(X, name)
            if isinstance(attr, types.MethodType):
                if name not in dir(Y):
                    msg = ('Method "%s" of "%s" was not found in "%s"'
                           % (name, X, Y))
                    raise Exception(msg)

    def same_API(X, Y, exclude=None):
        """Check that public methods of X and Y are the same.

        Args:
            * X, Y: Python objects
            * exclude: List of names to exclude from comparison or None
        """

        _same_API(X, Y, exclude=exclude)
        _same_API(Y, X, exclude=exclude)

        return True

### Navigation

- index
- modules
- Home »
- Contents »
- Module code »