File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ def requires_2fa(response):
19
19
20
20
class GitHubSession (requests .Session ):
21
21
auth = None
22
+ __attrs__ = requests .Session .__attrs__ + ['base_url' , 'two_factor_auth_cb' ]
22
23
23
24
def __init__ (self ):
24
25
super (GitHubSession , self ).__init__ ()
Original file line number Diff line number Diff line change
1
+ try :
2
+ import cPickle as pickle
3
+ except ImportError :
4
+ import pickle
5
+
1
6
import pytest
2
7
3
8
import requests
@@ -231,3 +236,14 @@ def test_retrieve_client_credentials_returns_none(self):
231
236
"""
232
237
s = self .build_session ()
233
238
assert s .retrieve_client_credentials () == (None , None )
239
+
240
+ def test_pickling (self ):
241
+ s = self .build_session ('https://api.github.com' )
242
+ dumped = pickle .dumps (s , pickle .HIGHEST_PROTOCOL )
243
+ loaded = pickle .loads (dumped )
244
+
245
+ assert hasattr (loaded , 'base_url' )
246
+ assert hasattr (loaded , 'two_factor_auth_cb' )
247
+
248
+ assert loaded .base_url == s .base_url
249
+ assert loaded .two_factor_auth_cb == s .two_factor_auth_cb
You can’t perform that action at this time.
0 commit comments