Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.

This commit is contained in:
Raymond Hettinger 2009-05-29 04:52:27 +00:00
parent ebe99ab344
commit 2bcde144ae
3 changed files with 28 additions and 3 deletions

View file

@ -254,11 +254,23 @@ class CellTest(unittest.TestCase):
self.assert_(cell(-36) == cell(-36.0))
self.assert_(cell(True) > empty_cell())
class StaticMethodAttrsTest(unittest.TestCase):
def test_func_attribute(self):
def f():
pass
c = classmethod(f)
self.assert_(c.__func__ is f)
s = staticmethod(f)
self.assert_(s.__func__ is f)
def test_main():
support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest,
ArbitraryFunctionAttrTest, FunctionDictsTest,
FunctionDocstringTest, CellTest)
FunctionDocstringTest, CellTest,
StaticMethodAttrsTest)
if __name__ == "__main__":
test_main()