diff options
author | Phillip J. Eby <pje@telecommunity.com> | 2006-03-28 00:07:24 (GMT) |
---|---|---|
committer | Phillip J. Eby <pje@telecommunity.com> | 2006-03-28 00:07:24 (GMT) |
commit | 35fd142435a5123d3ce740d14068034dab9ee5ec (patch) | |
tree | 6c1305021901f50654997d506c8f11c1d3bfec3e /Lib/test/test_contextlib.py | |
parent | d207b4f3767673a8cb54a20de26e4c10235fb78c (diff) | |
download | cpython-35fd142435a5123d3ce740d14068034dab9ee5ec.zip cpython-35fd142435a5123d3ce740d14068034dab9ee5ec.tar.gz cpython-35fd142435a5123d3ce740d14068034dab9ee5ec.tar.bz2 |
Fix contextlib not copying function attributes
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r-- | Lib/test/test_contextlib.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index 7d7f8d2..cd8895e 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -84,6 +84,21 @@ class ContextManagerTestCase(unittest.TestCase): raise ZeroDivisionError(999) self.assertEqual(state, [1, 42, 999]) + def test_contextmanager_attribs(self): + def attribs(**kw): + def decorate(func): + for k,v in kw.items(): + setattr(func,k,v) + return func + return decorate + @contextmanager + @attribs(foo='bar') + def baz(spam): + """Whee!""" + self.assertEqual(baz.__name__,'baz') + self.assertEqual(baz.foo, 'bar') + self.assertEqual(baz.__doc__, "Whee!") + class NestedTestCase(unittest.TestCase): # XXX This needs more work |