How to use the wrapt.six function in wrapt

To help you get started, we’ve selected a few wrapt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionelmc / python-lazy-object-proxy / tests / test_update_attributes.py View on Github external
def test_update_annotations_modified_on_original(self):
        def function():
            pass

        def wrapper(wrapped, instance, args, kwargs):
            return wrapped(*args, **kwargs)

        instance = wrapt.FunctionWrapper(function, wrapper)

        if six.PY3:
            self.assertEqual(instance.__annotations__, {})

        else:
            def run(*args):
                instance.__annotations__

            self.assertRaises(AttributeError, run, ())

        override_annotations = { 'override_annotations': '' }
        instance.__annotations__ = override_annotations

        self.assertEqual(function.__annotations__, override_annotations)
        self.assertEqual(instance.__annotations__, override_annotations)
github ionelmc / python-lazy-object-proxy / tests / test_adapter_py33.py View on Github external
def test_signature(self):
        # Test preservation of function argument specification. It
        # actually needs to match that of the adapter function the
        # prototype of which was supplied via the dummy function.

        if six.PY2:
            return

        def _adapter(arg1, arg2, *, arg3=None, **kwargs): pass

        function1a_signature = str(inspect.signature(_adapter))
        function1d_signature = str(inspect.signature(function1d))
        self.assertEqual(function1a_signature, function1d_signature)
github ionelmc / python-lazy-object-proxy / tests / test_update_attributes.py View on Github external
def test_update_qualname(self):

        @passthru_decorator
        def function():
            pass

        if six.PY3:
            method = self.test_update_qualname
            self.assertEqual(function.__qualname__,
                    (method.__qualname__ + '..function'))

        function.__qualname__ = 'override_qualname'

        self.assertEqual(function.__qualname__, 'override_qualname')
github ionelmc / python-lazy-object-proxy / tests / test_adapter.py View on Github external
def test_signature(self):
        # Test preservation of function argument specification. It
        # actually needs to match that of the adapter function the
        # prototype of which was supplied via the dummy function.

        if six.PY2:
            return

        def _adapter(arg1, arg2, arg3=None, *args, **kwargs): pass

        function1a_signature = str(inspect.signature(_adapter))
        function1d_signature = str(inspect.signature(function1d))
        self.assertEqual(function1a_signature, function1d_signature)