commit | author | age
|
5babba
|
1 |
import unittest |
CM |
2 |
|
0c29cf
|
3 |
|
5babba
|
4 |
class TestReify(unittest.TestCase): |
CM |
5 |
def _makeOne(self, wrapped): |
b60bdb
|
6 |
from pyramid.decorator import reify |
0c29cf
|
7 |
|
5babba
|
8 |
return reify(wrapped) |
CM |
9 |
|
|
10 |
def test___get__withinst(self): |
|
11 |
def wrapped(inst): |
|
12 |
return 'a' |
0c29cf
|
13 |
|
5babba
|
14 |
decorator = self._makeOne(wrapped) |
CM |
15 |
inst = Dummy() |
|
16 |
result = decorator.__get__(inst) |
|
17 |
self.assertEqual(result, 'a') |
|
18 |
self.assertEqual(inst.__dict__['wrapped'], 'a') |
|
19 |
|
|
20 |
def test___get__noinst(self): |
462af2
|
21 |
def wrapped(inst): |
3271c7
|
22 |
return 'a' # pragma: no cover |
0c29cf
|
23 |
|
462af2
|
24 |
decorator = self._makeOne(wrapped) |
5babba
|
25 |
result = decorator.__get__(None) |
CM |
26 |
self.assertEqual(result, decorator) |
|
27 |
|
462af2
|
28 |
|
5babba
|
29 |
class Dummy(object): |
CM |
30 |
pass |