File tree 2 files changed +4
-24
lines changed
2 files changed +4
-24
lines changed Original file line number Diff line number Diff line change @@ -318,27 +318,14 @@ def json(self): return json.loads(self.content)
318
318
get .reset_mock ()
319
319
get .return_value = MockJson (b'{"info": {"version": "0.0.1"}}' , 200 )
320
320
321
- # "back up" the value of this private class var and replace w/ default
322
- # so the ._version_check() method runs unencumbered:
323
- e_vdc__save = Epidata ._version_checked
324
- Epidata ._version_checked = False
325
- # run version check:
326
321
Epidata ._version_check ()
327
- # "restore" class var:
328
- Epidata ._version_checked = e_vdc__save
329
322
330
323
captured = self .capsys .readouterr ()
331
324
output = captured .err .splitlines ()
332
325
self .assertEqual (len (output ), 1 )
333
326
self .assertIn ("Client version not up to date" , output [0 ])
334
327
self .assertIn ("\' latest_version\' : \' 0.0.1\' " , output [0 ])
335
328
336
- @patch ('delphi.epidata.client.delphi_epidata.Epidata._version_check' )
337
- def test_version_check_once (self , version_check ):
338
- """Test that the _version_check() function is only called once on initial module import."""
339
- from delphi .epidata .client .delphi_epidata import Epidata
340
- version_check .assert_not_called ()
341
-
342
329
def test_geo_value (self ):
343
330
"""test different variants of geo types: single, *, multi."""
344
331
Original file line number Diff line number Diff line change @@ -46,25 +46,18 @@ class Epidata:
46
46
debug = False # if True, prints extra logging statements
47
47
sandbox = False # if True, will not execute any queries
48
48
49
- _version_checked = False
50
-
51
49
@staticmethod
52
50
def log (evt , ** kwargs ):
53
51
kwargs ['event' ] = evt
54
52
kwargs ['timestamp' ] = time .strftime ("%Y-%m-%d %H:%M:%S %z" )
55
53
return sys .stderr .write (str (kwargs ) + "\n " )
56
54
57
- # Check that this client's version matches the most recent available.
58
- # This is indended to run just once per program execution, on initial module load.
59
- # See the bottom of this file for the ultimate call to this method.
55
+ # Check that this client's version matches the most recent available. This
56
+ # is run just once per program execution, on initial module load (see the
57
+ # bottom of the file). This is a function of how Python's module system
58
+ # works: https://docs.python.org/3/reference/import.html#the-module-cache
60
59
@staticmethod
61
60
def _version_check ():
62
- if Epidata ._version_checked :
63
- # already done; nothing to do!
64
- return
65
-
66
- Epidata ._version_checked = True
67
-
68
61
try :
69
62
request = requests .get ('https://pypi.org/pypi/delphi-epidata/json' , timeout = 5 )
70
63
latest_version = request .json ()['info' ]['version' ]
You can’t perform that action at this time.
0 commit comments