summaryrefslogtreecommitdiff
path: root/Lib/test/support
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py9
-rw-r--r--Lib/test/support/script_helper.py3
2 files changed, 7 insertions, 5 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 15d8fc849b..345e16d754 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -777,8 +777,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
android_not_root = (is_android and os.geteuid() != 0)
if sys.platform != 'win32':
diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py
index ca5f9c20dd..1e746472ee 100644
--- a/Lib/test/support/script_helper.py
+++ b/Lib/test/support/script_helper.py
@@ -6,11 +6,8 @@ import importlib
import sys
import os
import os.path
-import tempfile
import subprocess
import py_compile
-import contextlib
-import shutil
import zipfile
from importlib.util import source_from_cache