@@ -13,11 +13,20 @@ def setup_class(cls):
13
13
auth = mock .Mock ()
14
14
cls .client = Client (auth )
15
15
16
+ def test_add_instance_methods (self ):
17
+ methods = [
18
+ ('_private' , 'private_method' ),
19
+ ('public' , 'public_method' )
20
+ ]
21
+ self .client ._add_instance_methods (methods )
22
+ assert self .client .public == 'public_method'
23
+ assert not hasattr (self .client , '_private' )
24
+
16
25
def test_make_connection_closes (self ):
17
26
mock_conn = mock .Mock ()
18
27
mock_conn .read .return_value = b'{}'
19
28
with mock .patch (
20
- 'six.moves.urllib.request.urlopen' , return_value = mock_conn ,
29
+ 'six.moves.urllib.request.urlopen' , return_value = mock_conn ,
21
30
):
22
31
self .client ._make_connection ("" )
23
32
mock_conn .close .assert_called_once_with ()
@@ -26,7 +35,7 @@ def test_make_connection_closes_with_exception(self):
26
35
mock_conn = mock .Mock ()
27
36
mock_conn .read .side_effect = Exception
28
37
with mock .patch (
29
- 'six.moves.urllib.request.urlopen' , return_value = mock_conn ,
38
+ 'six.moves.urllib.request.urlopen' , return_value = mock_conn ,
30
39
):
31
40
with pytest .raises (Exception ):
32
41
self .client ._make_connection ("" )
0 commit comments