forked from faif/python-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lazy.py
More file actions
28 lines (21 loc) · 983 Bytes
/
Copy pathtest_lazy.py
File metadata and controls
28 lines (21 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import unittest
from creational.lazy_evaluation import Person
class TestDynamicExpanding(unittest.TestCase):
def setUp(self):
self.John = Person('John', 'Coder')
def test_innate_properties(self):
self.assertDictEqual({'name': 'John', 'occupation': 'Coder'},
self.John.__dict__)
def test_relatives_not_in_properties(self):
self.assertNotIn('relatives', self.John.__dict__)
def test_extended_properties(self):
print(u"John's relatives: {0}".format(self.John.relatives))
self.assertDictEqual({'name': 'John', 'occupation': 'Coder',
'relatives': 'Many relatives.'},
self.John.__dict__)
def test_relatives_after_access(self):
print(u"John's relatives: {0}".format(self.John.relatives))
self.assertIn('relatives', self.John.__dict__)