Show testsetup code in rendered docs the right way.
Follow up to @tseaver comment at https://github.com/Pylons/pyramid/pull/2672#issuecomment-230310939
(cherry picked from commit 2061971)
| | |
| | | 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: |
| | | |
| | | .. 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 |
| | | |
| | | And usage of Foo: |
| | | Python parlance, a non-data descriptor. The following is an example and |
| | | its usage: |
| | | |
| | | .. doctest:: |
| | | |
| | | >>> from pyramid.decorator import reify |
| | | |
| | | >>> class Foo(object): |
| | | ... @reify |
| | | ... def jammy(self): |
| | | ... print('jammy called') |
| | | ... return 1 |
| | | |
| | | >>> f = Foo() |
| | | >>> v = f.jammy |
| | | jammy called |