Issue #26027, #27524: Add PEP 519/__fspath__() support to os and

os.path.

Thanks to Jelle Zijlstra for the initial patch against posixmodule.c.
This commit is contained in:
Brett Cannon 2016-08-26 14:44:48 -07:00
parent 6ed442c48d
commit 3f9183b5ac
11 changed files with 424 additions and 52 deletions

View file

@ -397,7 +397,7 @@ class PosixTester(unittest.TestCase):
self.assertTrue(posix.stat(fp.fileno()))
self.assertRaisesRegex(TypeError,
'should be string, bytes or integer, not',
'should be string, bytes, os.PathLike or integer, not',
posix.stat, float(fp.fileno()))
finally:
fp.close()
@ -409,16 +409,16 @@ class PosixTester(unittest.TestCase):
self.assertTrue(posix.stat(os.fsencode(support.TESTFN)))
self.assertWarnsRegex(DeprecationWarning,
'should be string, bytes or integer, not',
'should be string, bytes, os.PathLike or integer, not',
posix.stat, bytearray(os.fsencode(support.TESTFN)))
self.assertRaisesRegex(TypeError,
'should be string, bytes or integer, not',
'should be string, bytes, os.PathLike or integer, not',
posix.stat, None)
self.assertRaisesRegex(TypeError,
'should be string, bytes or integer, not',
'should be string, bytes, os.PathLike or integer, not',
posix.stat, list(support.TESTFN))
self.assertRaisesRegex(TypeError,
'should be string, bytes or integer, not',
'should be string, bytes, os.PathLike or integer, not',
posix.stat, list(os.fsencode(support.TESTFN)))
@unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")