[Python-checkins] python/dist/src/Lib/test test_decorators.py, 1.5, 1.6

bcannon at users.sourceforge.net bcannon at users.sourceforge.net
Thu Aug 19 05:48:28 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9244/Lib/test

Modified Files:
	test_decorators.py 
Log Message:
Rewrite test_order so as to be more "proper".  Originally relied on an
error based on decorating with staticmethod too soon for the code to execute.
This meant that if the test didn't pass it just errored out.  Now if the test
doesn't pass it leads to a failure instead.


Index: test_decorators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_decorators.py	17 Aug 2004 17:29:15 -0000	1.5
--- test_decorators.py	19 Aug 2004 03:48:24 -0000	1.6
***************
*** 192,202 ****
  
      def test_order(self):
!         class C(object):
!             @staticmethod
!             @funcattrs(abc=1)
!             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_eval_order(self):
--- 192,208 ----
  
      def test_order(self):
!         # Test that decorators are applied in the proper order to the function
!         # they are decorating.
!         def callnum(num):
!             """Decorator factory that returns a decorator that replaces the
!             passed-in function with one that returns the value of 'num'"""
!             def deco(func):
!                 return lambda: num
!             return deco
!         @callnum(2)
!         @callnum(1)
!         def foo(): return 42
!         self.assertEqual(foo(), 2,
!                             "Application order of decorators is incorrect")
  
      def test_eval_order(self):



More information about the Python-checkins mailing list