~ubuntu-branches/ubuntu/quantal/python-gevent/quantal

« back to all changes in this revision

Viewing changes to greentest/test__lazy_property.py

  • Committer: Bazaar Package Importer
  • Author(s): Örjan Persson
  • Date: 2011-05-17 16:43:20 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110517164320-nwhld2xo6sz58p4m
Tags: 0.13.6-1
New upstream version (Closes: #601863).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from gevent.util import lazy_property
2
 
 
3
 
calc = []
4
 
 
5
 
class A(object):
6
 
 
7
 
    @lazy_property
8
 
    def prop(self):
9
 
        calc.append(1)
10
 
        return 1
11
 
 
12
 
a = A()
13
 
assert a.prop == 1
14
 
assert calc == [1], calc
15
 
assert a.prop == 1
16
 
assert calc == [1], calc
17
 
a.__dict__['prop'] = 5
18
 
assert a.prop == 5
19
 
assert calc == [1], calc