summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-12-02 00:13:46 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-12-02 00:13:46 (GMT)
commitd6958ac6c0fec90524bf9c4999c8bc75fff0c71b (patch)
tree93f5e47349d8b51b9cec9f2c1710b8dc1e13c98b /Lib/test/support
parentedfe8869c8e888e676091c87330b3bf0f3d9814b (diff)
downloadcpython-d6958ac6c0fec90524bf9c4999c8bc75fff0c71b.zip
cpython-d6958ac6c0fec90524bf9c4999c8bc75fff0c71b.tar.gz
cpython-d6958ac6c0fec90524bf9c4999c8bc75fff0c71b.tar.bz2
Add sys.getandroidapilevel()
Issue #28740: Add sys.getandroidapilevel(): return the build time API version of Android as an integer. Function only available on Android.
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 52c908e..eb5a89a 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -766,8 +766,13 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma')
is_jython = sys.platform.startswith('java')
-_ANDROID_API_LEVEL = sysconfig.get_config_var('ANDROID_API_LEVEL')
-is_android = (_ANDROID_API_LEVEL is not None and _ANDROID_API_LEVEL > 0)
+try:
+ # constant used by requires_android_level()
+ _ANDROID_API_LEVEL = sys.getandroidapilevel()
+ is_android = True
+except AttributeError:
+ # sys.getandroidapilevel() is only available on Android
+ is_android = False
if sys.platform != 'win32':
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'