[Python-checkins] bpo-26856: Skip test_pwd on Android until issue 32033 is fixed (GH-4561)

xdegaye webhook-mailer at python.org
Sat Nov 25 11:32:30 EST 2017


https://github.com/python/cpython/commit/76fdac4c9f53eb8433a54bd3daf9f5cc2e702a44
commit: 76fdac4c9f53eb8433a54bd3daf9f5cc2e702a44
branch: master
author: xdegaye <xdegaye at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017年11月25日T17:32:27+01:00
summary:
bpo-26856: Skip test_pwd on Android until issue 32033 is fixed (GH-4561)
files:
M Lib/test/test_pwd.py
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index ac9cff789ee..c13a7c9294f 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -4,19 +4,11 @@
 
 pwd = support.import_module('pwd')
 
-def _getpwall():
- # Android does not have getpwall.
- if hasattr(pwd, 'getpwall'):
- return pwd.getpwall()
- elif hasattr(pwd, 'getpwuid'):
- return [pwd.getpwuid(0)]
- else:
- return []
-
+ at unittest.skipUnless(hasattr(pwd, 'getpwall'), 'Does not have getpwall()')
 class PwdTest(unittest.TestCase):
 
 def test_values(self):
- entries = _getpwall()
+ entries = pwd.getpwall()
 
 for e in entries:
 self.assertEqual(len(e), 7)
@@ -42,7 +34,7 @@ def test_values(self):
 # and check afterwards (done in test_values_extended)
 
 def test_values_extended(self):
- entries = _getpwall()
+ entries = pwd.getpwall()
 entriesbyname = {}
 entriesbyuid = {}
 
@@ -66,13 +58,12 @@ def test_errors(self):
 self.assertRaises(TypeError, pwd.getpwuid, 3.14)
 self.assertRaises(TypeError, pwd.getpwnam)
 self.assertRaises(TypeError, pwd.getpwnam, 42)
- if hasattr(pwd, 'getpwall'):
- self.assertRaises(TypeError, pwd.getpwall, 42)
+ self.assertRaises(TypeError, pwd.getpwall, 42)
 
 # try to get some errors
 bynames = {}
 byuids = {}
- for (n, p, u, g, gecos, d, s) in _getpwall():
+ for (n, p, u, g, gecos, d, s) in pwd.getpwall():
 bynames[n] = u
 byuids[u] = n
 
@@ -106,17 +97,13 @@ def test_errors(self):
 # loop, say), pwd.getpwuid() might still be able to find data for that
 # uid. Using sys.maxint may provoke the same problems, but hopefully
 # it will be a more repeatable failure.
- # Android accepts a very large span of uids including sys.maxsize and
- # -1; it raises KeyError with 1 or 2 for example.
 fakeuid = sys.maxsize
 self.assertNotIn(fakeuid, byuids)
- if not support.is_android:
- self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
+ self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
 
 # -1 shouldn't be a valid uid because it has a special meaning in many
 # uid-related functions
- if not support.is_android:
- self.assertRaises(KeyError, pwd.getpwuid, -1)
+ self.assertRaises(KeyError, pwd.getpwuid, -1)
 # should be out of uid_t range
 self.assertRaises(KeyError, pwd.getpwuid, 2**128)
 self.assertRaises(KeyError, pwd.getpwuid, -2**128)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /