Package: src:python-wrapt
Version: 1.11.2-2
Severity: important
Tags: sid bullseye
User: debian-pyt...@lists.debian.org
Usertags: python3.9

=================================== FAILURES ===================================
_____________ TestCallingOuterClassMethod.test_class_call_function _____________

self = <test_outer_classmethod.TestCallingOuterClassMethod
testMethod=test_class_call_function>

    def test_class_call_function(self):
        # Test calling classmethod. The instance and class passed to the
        # wrapper will both be None because our decorator is surrounded
        # by the classmethod decorator. The classmethod decorator
        # doesn't bind the method and treats it like a normal function,
        # explicitly passing the class as the first argument with the
        # actual arguments following that.

        _args = (1, 2)
        _kwargs = {'one': 1, 'two': 2}

        @wrapt.decorator
        def _decorator(wrapped, instance, args, kwargs):
            self.assertEqual(instance, None)
            self.assertEqual(args, (Class,)+_args)
            self.assertEqual(kwargs, _kwargs)
            self.assertEqual(wrapped.__module__, _function.__module__)
            self.assertEqual(wrapped.__name__, _function.__name__)
            return wrapped(*args, **kwargs)

        @_decorator
        def _function(*args, **kwargs):
            return args, kwargs

        class Class(object):
            @classmethod
            @_decorator
            def _function(cls, *args, **kwargs):
                return (args, kwargs)

>       result = Class._function(*_args, **_kwargs)

tests/test_outer_classmethod.py:153:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/wrapt/wrappers.py:602: in __call__
    return self._self_wrapper(self.__wrapped__, self._self_instance,
tests/test_outer_classmethod.py:136: in _decorator
    self.assertEqual(instance, None)
E   AssertionError: <class 'test_outer_classmethod.TestCallin[54 chars]ass'> != 
None
___________ TestCallingOuterClassMethod.test_instance_call_function ____________

self = <test_outer_classmethod.TestCallingOuterClassMethod
testMethod=test_instance_call_function>

    def test_instance_call_function(self):
        # Test calling classmethod via class instance. The instance
        # and class passed to the wrapper will both be None because our
        # decorator is surrounded by the classmethod decorator. The
        # classmethod decorator doesn't bind the method and treats it
        # like a normal function, explicitly passing the class as the
        # first argument with the actual arguments following that.

        _args = (1, 2)
        _kwargs = {'one': 1, 'two': 2}

        @wrapt.decorator
        def _decorator(wrapped, instance, args, kwargs):
            self.assertEqual(instance, None)
            self.assertEqual(args, (Class,)+_args)
            self.assertEqual(kwargs, _kwargs)
            self.assertEqual(wrapped.__module__, _function.__module__)
            self.assertEqual(wrapped.__name__, _function.__name__)
            return wrapped(*args, **kwargs)

        @_decorator
        def _function(*args, **kwargs):
            return args, kwargs

        class Class(object):
            @classmethod
            @_decorator
            def _function(cls, *args, **kwargs):
                return (args, kwargs)

>       result = Class()._function(*_args, **_kwargs)

tests/test_outer_classmethod.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/wrapt/wrappers.py:602: in __call__
    return self._self_wrapper(self.__wrapped__, self._self_instance,
tests/test_outer_classmethod.py:170: in _decorator
    self.assertEqual(instance, None)
E   AssertionError: <class 'test_outer_classmethod.TestCallin[57 chars]ass'> != 
None
_____________ TestSynchronized.test_synchronized_outer_classmethod _____________

self = <test_synchronized_lock.TestSynchronized
testMethod=test_synchronized_outer_classmethod>

    def test_synchronized_outer_classmethod(self):
        # XXX If all was good, this would be detected as a class
        # method call, but the classmethod decorator doesn't bind
        # the wrapped function to the class before calling and
        # just calls it direct, explicitly passing the class as
        # first argument. This screws things up. Would be nice if
        # Python were fixed, but that isn't likely to happen.

        #_lock0 = getattr(C4, '_synchronized_lock', None)
        _lock0 = getattr(C4.function2, '_synchronized_lock', None)
        self.assertEqual(_lock0, None)

        c4.function2()

        #_lock1 = getattr(C4, '_synchronized_lock', None)
        _lock1 = getattr(C4.function2, '_synchronized_lock', None)
>       self.assertNotEqual(_lock1, None)
E       AssertionError: None == None

tests/test_synchronized_lock.py:163: AssertionError

Reply via email to