summaryrefslogtreecommitdiff
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2016-06-04 10:19:27 -0700
committerEthan Furman <ethan@stoneleaf.us>2016-06-04 10:19:27 -0700
commitc1cbeedf0c650c3f7c64f04479070d39e15e1baf (patch)
treeaf1e666a424da1ec083a1bb8363b529413809134 /Lib/test/test_os.py
parent7a3827f61f8d3875bd2611aee5f5a5e5e2913907 (diff)
downloadcpython-git-c1cbeedf0c650c3f7c64f04479070d39e15e1baf.tar.gz
issue27182: update fsencode and fsdecode for os.path(); patch by Dusty Phillips
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index f52de28768..84ef150f82 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -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():