diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-08-31 13:13:46 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-08-31 13:13:46 +0000 |
| commit | 2d4f61826a0ebc5330b869713abf7a36a69c0e6a (patch) | |
| tree | 15ab99d60d0fadc5a8824db16934dd744ab6053e | |
| parent | 211c300c104313796b1d298e3d95db2d5adaf848 (diff) | |
| download | pyramid-2d4f61826a0ebc5330b869713abf7a36a69c0e6a.tar.gz pyramid-2d4f61826a0ebc5330b869713abf7a36a69c0e6a.tar.bz2 pyramid-2d4f61826a0ebc5330b869713abf7a36a69c0e6a.zip | |
- The reify decorator now maintains the docstring of the function it
wraps.
| -rw-r--r-- | CHANGES.txt | 3 | ||||
| -rw-r--r-- | repoze/bfg/decorator.py | 4 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_decorator.py | 6 |
3 files changed, 13 insertions, 0 deletions
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 |
