[Python-checkins] python/dist/src/Lib/test test_datetime.py, 1.50, 1.51 test_descr.py, 1.202, 1.203 test_descrtut.py, 1.20, 1.21 test_doctest2.py, 1.6, 1.7 test_userdict.py, 1.20, 1.21

gvanrossum at users.sourceforge.net gvanrossum at users.sourceforge.net
Sun Jan 16 01:25:49 CET 2005


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

Modified Files:
	test_datetime.py test_descr.py test_descrtut.py 
	test_doctest2.py test_userdict.py 
Log Message:
Use descriptors.


Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- test_datetime.py	13 Jan 2005 04:12:27 -0000	1.50
+++ test_datetime.py	16 Jan 2005 00:25:30 -0000	1.51
@@ -446,9 +446,9 @@
     def test_subclass_timedelta(self):
 
         class T(timedelta):
+            @staticmethod
             def from_td(td):
                 return T(td.days, td.seconds, td.microseconds)
-            from_td = staticmethod(from_td)
 
             def as_hours(self):
                 sum = (self.days * 24 +

Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -d -r1.202 -r1.203
--- test_descr.py	7 Aug 2004 20:30:03 -0000	1.202
+++ test_descr.py	16 Jan 2005 00:25:31 -0000	1.203
@@ -691,13 +691,13 @@
     class _instance(object):
         pass
     class M2(object):
+        @staticmethod
         def __new__(cls, name, bases, dict):
             self = object.__new__(cls)
             self.name = name
             self.bases = bases
             self.dict = dict
             return self
-        __new__ = staticmethod(__new__)
         def __call__(self):
             it = _instance()
             # Early binding of methods
@@ -2071,9 +2071,9 @@
         aProp = property(lambda self: "foo")
 
     class Sub(Base):
+        @classmethod
         def test(klass):
             return super(Sub,klass).aProp
-        test = classmethod(test)
 
     veris(Sub.test(), Base.aProp)
 

Index: test_descrtut.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- test_descrtut.py	2 Jul 2004 06:41:05 -0000	1.20
+++ test_descrtut.py	16 Jan 2005 00:25:31 -0000	1.21
@@ -246,9 +246,9 @@
 
     >>> class C:
     ...
+    ...     @staticmethod
     ...     def foo(x, y):
     ...         print "staticmethod", x, y
-    ...     foo = staticmethod(foo)
 
     >>> C.foo(1, 2)
     staticmethod 1 2
@@ -260,9 +260,9 @@
 implicit first argument that is the *class* for which they are invoked.
 
     >>> class C:
+    ...     @classmethod
     ...     def foo(cls, y):
     ...         print "classmethod", cls, y
-    ...     foo = classmethod(foo)
 
     >>> C.foo(1)
     classmethod test.test_descrtut.C 1
@@ -286,10 +286,10 @@
 But notice this:
 
     >>> class E(C):
+    ...     @classmethod
     ...     def foo(cls, y): # override C.foo
     ...         print "E.foo() called"
     ...         C.foo(y)
-    ...     foo = classmethod(foo)
 
     >>> E.foo(1)
     E.foo() called

Index: test_doctest2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest2.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_doctest2.py	13 Oct 2004 14:15:32 -0000	1.6
+++ test_doctest2.py	16 Jan 2005 00:25:31 -0000	1.7
@@ -80,6 +80,7 @@
         -12
         """)
 
+    @staticmethod
     def statm():
         """
         A static method.
@@ -91,8 +92,7 @@
         """
         return 666
 
-    statm = staticmethod(statm)
-
+    @classmethod
     def clsm(cls, val):
         """
         A class method.
@@ -104,8 +104,6 @@
         """
         return val
 
-    clsm = classmethod(clsm)
-
 def test_main():
     from test import test_doctest2
     EXPECTED = 19

Index: test_userdict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- test_userdict.py	2 Jun 2004 18:42:25 -0000	1.20
+++ test_userdict.py	16 Jan 2005 00:25:31 -0000	1.21
@@ -191,12 +191,12 @@
         for key, value in self.iteritems():
             d[key] = value
         return d
+    @classmethod
     def fromkeys(cls, keys, value=None):
         d = cls()
         for key in keys:
             d[key] = value
         return d
-    fromkeys = classmethod(fromkeys)
 
 class UserDictMixinTest(mapping_tests.TestMappingProtocol):
     type2test = SeqDict



More information about the Python-checkins mailing list