From 01d7eba3162af8a0f62d7636cbb44440901b3909 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 19 Feb 2012 01:10:25 -0500 Subject: allow arbitrary attributes on classmethod and staticmethod (closes #14051) --- Lib/test/test_descr.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Lib') diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 2b2026cee9..22277798f6 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1443,6 +1443,13 @@ order (MRO) for bases """ else: self.fail("classmethod shouldn't accept keyword args") + cm = classmethod(f) + cm.x = 42 + self.assertEqual(cm.x, 42) + self.assertEqual(cm.__dict__, {"x" : 42}) + del cm.x + self.assertFalse(hasattr(cm, "x")) + @support.impl_detail("the module 'xxsubtype' is internal") def test_classmethods_in_c(self): # Testing C-based class methods... @@ -1474,6 +1481,12 @@ order (MRO) for bases """ self.assertEqual(d.goo(1), (1,)) self.assertEqual(d.foo(1), (d, 1)) self.assertEqual(D.foo(d, 1), (d, 1)) + sm = staticmethod(None) + sm.x = 42 + self.assertEqual(sm.x, 42) + self.assertEqual(sm.__dict__, {"x" : 42}) + del sm.x + self.assertFalse(hasattr(sm, "x")) @support.impl_detail("the module 'xxsubtype' is internal") def test_staticmethods_in_c(self): -- cgit v1.2.1