Add sys.getandroidapilevel()

Issue #28740: Add sys.getandroidapilevel(): return the build time
API version of Android as an integer.

Function only available on Android.
This commit is contained in:
Victor Stinner 2016-12-02 01:13:46 +01:00
parent edfe8869c8
commit d6958ac6c0
5 changed files with 44 additions and 2 deletions

View file

@ -826,6 +826,13 @@ class SysModuleTest(unittest.TestCase):
rc, stdout, stderr = assert_python_ok('-c', code)
self.assertEqual(stdout.rstrip(), b'True')
@unittest.skipUnless(hasattr(sys, 'getandroidapilevel'),
'need sys.getandroidapilevel()')
def test_getandroidapilevel(self):
level = sys.getandroidapilevel()
self.assertIsInstance(level, int)
self.assertGreater(level, 0)
@test.support.cpython_only
class SizeofTest(unittest.TestCase):