From abcfdc58a87cf649b4c761aab6aeb79fb48835f7 Mon Sep 17 00:00:00 2001 From: Andy Mikhaylenko Date: Fri, 3 Jan 2014 00:26:21 +0600 Subject: [PATCH] Add more tests re #51 --- test/test_decorators.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test_decorators.py b/test/test_decorators.py index d169d4c..37d7556 100644 --- a/test/test_decorators.py +++ b/test/test_decorators.py @@ -37,15 +37,39 @@ def func(): assert attr == 'new-name' +def test_named_proxy(): + @argh.named('new-name') + def func(self): + pass + + proxied_func = argh.named('another-name')(func) + + assert getattr(func, argh.constants.ATTR_NAME) == 'new-name' + assert getattr(proxied_func, argh.constants.ATTR_NAME) == 'another-name' + + def test_named_method(): class A: @argh.named('new-name') def meth(self): pass + assert getattr(A.meth, argh.constants.ATTR_NAME) == 'new-name' assert getattr(A().meth, argh.constants.ATTR_NAME) == 'new-name' +def test_named_method_proxy(): + class A: + @argh.named('new-name') + def meth(self): + pass + + a = A() + proxied_meth = argh.named('another-name')(a.meth) + assert getattr(a.meth, argh.constants.ATTR_NAME) == 'new-name' + assert getattr(proxied_meth, argh.constants.ATTR_NAME) == 'another-name' + + def test_command(): @argh.command def func():