From e33e89d2c75b85e9a0fc35e8261567e8acd59c81 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 2 Dec 2016 01:13:46 +0100 Subject: Add sys.getandroidapilevel() Issue #28740: Add sys.getandroidapilevel(): return the build time API version of Android as an integer. Function only available on Android. --- Lib/test/support/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 52c908e028..eb5a89aaf4 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' -- cgit v1.2.1