[Python-checkins] python/dist/src/Lib/test test_decorators.py, 1.3,
1.4
bcannon at users.sourceforge.net
bcannon at users.sourceforge.net
Sun Aug 15 09:21:27 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31674/Lib/test
Modified Files:
test_decorators.py
Log Message:
Correct the order of application for decorators. Meant to be bottom-up and not
top-down. Now matches the PEP.
Index: test_decorators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_decorators.py 4 Aug 2004 02:36:18 -0000 1.3
--- test_decorators.py 15 Aug 2004 07:21:25 -0000 1.4
***************
*** 130,134 ****
# see the comment in countcalls.
counts = {}
! @countcalls(counts) @memoize
def double(x):
return x * 2
--- 130,135 ----
# see the comment in countcalls.
counts = {}
! @memoize
! @countcalls(counts)
def double(x):
return x * 2
***************
*** 187,196 ****
def test_order(self):
! class C(object):
! @funcattrs(abc=1) @staticmethod
! def foo(): return 42
! # This wouldn't work if staticmethod was called first
! self.assertEqual(C.foo(), 42)
! self.assertEqual(C().foo(), 42)
def test_main():
--- 188,205 ----
def test_order(self):
! # Test that decorators are conceptually applied right-recursively;
! # that means bottom-up
! def ordercheck(num):
! def deco(func):
! return lambda: num
! return deco
!
! # Should go ordercheck(1)(ordercheck(2)(blah)) which should lead to
! # blah() == 1
! @ordercheck(1)
! @ordercheck(2)
! def blah(): pass
! self.assertEqual(blah(), 1, "decorators are meant to be applied "
! "bottom-up")
def test_main():
More information about the Python-checkins
mailing list