File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+
4+ from bridge import DrawingAPI1 , DrawingAPI2 , CircleShape
5+ from sys import version_info
6+
7+ if version_info < (2 , 7 ):
8+ import unittest2 as unittest
9+ else :
10+ import unittest
11+
12+ from unittest .mock import patch
13+
14+ class BridgeTest (unittest .TestCase ):
15+
16+ def test_bridge_shall_draw_with_concrete_implementation (cls ):
17+ ci1 = DrawingAPI1 ()
18+ ci2 = DrawingAPI2 ()
19+ with patch .object (ci1 , 'draw_circle' ) as mock_ci1_draw_circle ,\
20+ patch .object (ci2 , 'draw_circle' ) as mock_ci2_draw_circle :
21+ sh1 = CircleShape (1 , 2 , 3 , ci1 )
22+ sh1 .draw ()
23+ cls .assertEqual (mock_ci1_draw_circle .call_count , 1 )
24+ sh2 = CircleShape (1 , 2 , 3 , ci2 )
25+ sh2 .draw ()
26+ cls .assertEqual (mock_ci2_draw_circle .call_count , 1 )
27+
28+ if __name__ == "__main__" :
29+ unittest .main ()
30+
You can’t perform that action at this time.
0 commit comments