diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-02-19 06:10:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-02-19 06:10:25 (GMT) |
commit | 01d7eba3162af8a0f62d7636cbb44440901b3909 (patch) | |
tree | cd38f465ca59199a663e3846d45384cfa5579137 /Lib | |
parent | dc1d3eda1f7fe45f111f6e6d58635de06e04e655 (diff) | |
download | cpython-01d7eba3162af8a0f62d7636cbb44440901b3909.zip cpython-01d7eba3162af8a0f62d7636cbb44440901b3909.tar.gz cpython-01d7eba3162af8a0f62d7636cbb44440901b3909.tar.bz2 |
allow arbitrary attributes on classmethod and staticmethod (closes #14051)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 2b2026c..2227779 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): |