Skip to content

Commit 7eab59d

Browse files
committed
Merge branch 'dev' of https://github.com/0--key/python-patterns into dev
2 parents c7449f7 + 817b8a6 commit 7eab59d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_lazy.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import unittest
4+
from creational.lazy_evaluation import Person
5+
6+
7+
class TestDynamicExpanding(unittest.TestCase):
8+
9+
def setUp(self):
10+
self.John = Person('John', 'Coder')
11+
12+
def test_innate_properties(self):
13+
self.assertDictEqual({'name': 'John', 'occupation': 'Coder'},
14+
self.John.__dict__)
15+
16+
def test_relatives_not_in_properties(self):
17+
self.assertNotIn('relatives', self.John.__dict__)
18+
19+
def test_extended_properties(self):
20+
print("Jhon's relatives: {0}".format(self.John.relatives))
21+
self.assertDictEqual({'name': 'John', 'occupation': 'Coder',
22+
'relatives': 'Many relatives.'},
23+
self.John.__dict__)
24+
25+
def test_relatives_after_access(self):
26+
print("Jhon's relatives: {0}".format(self.John.relatives))
27+
self.assertIn('relatives', self.John.__dict__)

0 commit comments

Comments
 (0)