From 2061971ccddff626fc435b16f0afabefee9a260e Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Mon, 4 Jul 2016 14:04:34 -0700 Subject: Show testsetup code in rendered docs the right way. Follow up to @tseaver comment at https://github.com/Pylons/pyramid/pull/2672#issuecomment-230310939 --- pyramid/decorator.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/pyramid/decorator.py b/pyramid/decorator.py index e3a8c707f..065a3feed 100644 --- a/pyramid/decorator.py +++ b/pyramid/decorator.py @@ -6,31 +6,18 @@ class reify(object): Python ``@property`` decorator, but it puts the result of the method it decorates into the instance dict after the first call, effectively replacing the function it decorates with an instance variable. It is, in - Python parlance, a non-data descriptor. An example: + Python parlance, a non-data descriptor. The following is an example and + its usage: - .. code-block:: python - - from pyramid.decorator import reify - - class Foo(object): - @reify - def jammy(self): - print('jammy called') - return 1 - - .. testsetup:: - - from pyramid.decorator import reify - - class Foo(object): - @reify - def jammy(self): - print('jammy called') - return 1 + .. doctest:: - And usage of Foo: + >>> from pyramid.decorator import reify - .. doctest:: + >>> class Foo(object): + ... @reify + ... def jammy(self): + ... print('jammy called') + ... return 1 >>> f = Foo() >>> v = f.jammy -- cgit v1.2.3