From 2d4f61826a0ebc5330b869713abf7a36a69c0e6a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 31 Aug 2010 13:13:46 +0000 Subject: - The reify decorator now maintains the docstring of the function it wraps. --- CHANGES.txt | 3 +++ repoze/bfg/decorator.py | 4 ++++ repoze/bfg/tests/test_decorator.py | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index e0e0700c2..a20c26c0e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -88,6 +88,9 @@ Internal - Make tests runnable again under Jython (although they do not all pass currently). +- The reify decorator now maintains the docstring of the function it + wraps. + 1.3a8 (2010-08-08) ================== diff --git a/repoze/bfg/decorator.py b/repoze/bfg/decorator.py index d30a06658..98d7b36b5 100644 --- a/repoze/bfg/decorator.py +++ b/repoze/bfg/decorator.py @@ -6,6 +6,10 @@ class reify(object): def __init__(self, wrapped): self.wrapped = wrapped + try: + self.__doc__ = wrapped.__doc__ + except: # pragma: no cover + pass def __get__(self, inst, objtype=None): if inst is None: diff --git a/repoze/bfg/tests/test_decorator.py b/repoze/bfg/tests/test_decorator.py index b1ac2252d..d41c62c65 100644 --- a/repoze/bfg/tests/test_decorator.py +++ b/repoze/bfg/tests/test_decorator.py @@ -19,5 +19,11 @@ class TestReify(unittest.TestCase): result = decorator.__get__(None) self.assertEqual(result, decorator) + def test___doc__copied(self): + def wrapped(inst): + """My doc""" + decorator = self._makeOne(wrapped) + self.assertEqual(decorator.__doc__, "My doc") + class Dummy(object): pass -- cgit v1.2.3