File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
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__ )
You can’t perform that action at this time.
0 commit comments