mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
issue27182: update fsencode and fsdecode for os.path(); patch by Dusty Phillips
This commit is contained in:
parent
7a3827f61f
commit
c1cbeedf0c
2 changed files with 29 additions and 8 deletions
|
@ -3106,6 +3106,21 @@ class TestPEP519(unittest.TestCase):
|
|||
for s in 'hello', 'goodbye', 'some/path/and/file':
|
||||
self.assertEqual(s, os.fspath(s))
|
||||
|
||||
def test_fsencode_fsdecode_return_pathlike(self):
|
||||
class Pathlike:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def __fspath__(self):
|
||||
return self.path
|
||||
|
||||
for p in "path/like/object", b"path/like/object":
|
||||
pathlike = Pathlike(p)
|
||||
|
||||
self.assertEqual(p, os.fspath(pathlike))
|
||||
self.assertEqual(b"path/like/object", os.fsencode(pathlike))
|
||||
self.assertEqual("path/like/object", os.fsdecode(pathlike))
|
||||
|
||||
def test_garbage_in_exception_out(self):
|
||||
vapor = type('blah', (), {})
|
||||
for o in int, type, os, vapor():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue