(self)
| 361 | @unittest.skipIf(sys.platform == "vxworks", |
| 362 | "no home directory on VxWorks") |
| 363 | def test_expanduser_pwd2(self): |
| 364 | pwd = import_helper.import_module('pwd') |
| 365 | getpwall = support.get_attribute(pwd, 'getpwall') |
| 366 | names = [entry.pw_name for entry in getpwall()] |
| 367 | maxusers = 1000 if support.is_resource_enabled('cpu') else 100 |
| 368 | if len(names) > maxusers: |
| 369 | # Select random names, half of them with non-ASCII name, |
| 370 | # if available. |
| 371 | random.shuffle(names) |
| 372 | names.sort(key=lambda name: name.isascii()) |
| 373 | del names[maxusers//2:-maxusers//2] |
| 374 | for name in names: |
| 375 | # gh-121200: pw_dir can be different between getpwall() and |
| 376 | # getpwnam(), so use getpwnam() pw_dir as expanduser() does. |
| 377 | entry = pwd.getpwnam(name) |
| 378 | home = entry.pw_dir |
| 379 | home = home.rstrip('/') or '/' |
| 380 | |
| 381 | with self.subTest(name=name, pw_dir=entry.pw_dir): |
| 382 | self.assertEqual(posixpath.expanduser('~' + name), home) |
| 383 | self.assertEqual(posixpath.expanduser(os.fsencode('~' + name)), |
| 384 | os.fsencode(home)) |
| 385 | |
| 386 | NORMPATH_CASES = [ |
| 387 | ("", "."), |
nothing calls this directly
no test coverage detected