File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
googleapiclient/discovery_cache Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import logging
20
20
import datetime
21
-
21
+ import os
22
22
23
23
LOGGER = logging .getLogger (__name__ )
24
24
@@ -32,16 +32,18 @@ def autodetect():
32
32
googleapiclient.discovery_cache.base.Cache, a cache object which
33
33
is auto detected, or None if no cache object is available.
34
34
"""
35
- try :
36
- from google .appengine .api import memcache
37
- from . import appengine_memcache
38
-
39
- return appengine_memcache .cache
40
- except Exception :
35
+ if 'APPENGINE_RUNTIME' in os .environ :
41
36
try :
42
- from . import file_cache
37
+ from google .appengine .api import memcache
38
+ from . import appengine_memcache
39
+
40
+ return appengine_memcache .cache
41
+ except Exception :
42
+ pass
43
+ try :
44
+ from . import file_cache
43
45
44
- return file_cache .cache
45
- except Exception as e :
46
- LOGGER .warning (e , exc_info = True )
47
- return None
46
+ return file_cache .cache
47
+ except Exception as e :
48
+ LOGGER .warning (e , exc_info = True )
49
+ return None
Original file line number Diff line number Diff line change @@ -648,6 +648,14 @@ def test_api_endpoint_override_from_client_options_dict(self):
648
648
649
649
650
650
class DiscoveryFromAppEngineCache (unittest .TestCase ):
651
+
652
+ def setUp (self ):
653
+ self .old_environ = os .environ .copy ()
654
+ os .environ ["APPENGINE_RUNTIME" ] = "python27"
655
+
656
+ def tearDown (self ):
657
+ os .environ = self .old_environ
658
+
651
659
def test_appengine_memcache (self ):
652
660
# Hack module import
653
661
self .orig_import = __import__
You can’t perform that action at this time.
0 commit comments