예제 #1
0
    def test_wrapped_empty_list(self, PluggableDecorator, config):
        def myfunc(a, b):
            """myfunc"""
            return a + b

        myfunc2 = PluggableDecorator('decorator_list')(myfunc)
        assert hasattr(myfunc, '__wrapped__') is False
        assert myfunc2.__wrapped__ is myfunc
예제 #2
0
    def test_no_config(self, PluggableDecorator, config):
        decorator = PluggableDecorator('decorator_list')

        @decorator
        def myfunc(a, b):
            """myfunc"""
            return a + b

        result = myfunc(2, 3)
        assert result == 5
        assert myfunc.__doc__ == "myfunc"
예제 #3
0
    def test_wrapped(self, PluggableDecorator, config):
        config['decorator_list'] = [
            'palladium.tests.test_util.dec1',
            'palladium.tests.test_util.dec2']

        def myfunc(a, b):
            """myfunc"""
            return a + b

        myfunc2 = PluggableDecorator('decorator_list')(myfunc)
        assert hasattr(myfunc, '__wrapped__') is False
        assert hasattr(myfunc2, '__wrapped__') is True
        assert myfunc2.__wrapped__ is myfunc
예제 #4
0
    def test_two_decorators(self, PluggableDecorator, config):
        config['decorator_list'] = [
            'palladium.tests.test_util.dec1',
            'palladium.tests.test_util.dec2']
        decorator = PluggableDecorator('decorator_list')

        @decorator
        def myfunc(a, b):
            """myfunc"""
            return a + b

        result = myfunc(2, 3)
        assert result == 52
        assert myfunc.__doc__ == "myfunc"