Skip to content

Commit

Permalink
Add more tests re #51
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere committed Jan 2, 2014
1 parent c2248ca commit abcfdc5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit abcfdc5

Please sign in to comment.