summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-07-11 03:36:46 (GMT)
committerGitHub <noreply@github.com>2017-07-11 03:36:46 (GMT)
commit1180e5a51871fa53ca6892e83fd2e69dc2600447 (patch)
treeb05732085cdc4aa1995c163f32bc7a04927cef7b /Lib/test/test_os.py
parent4f9a446f3fb42f800e73cd9414dd1eccb3ca4fa7 (diff)
downloadcpython-1180e5a51871fa53ca6892e83fd2e69dc2600447.zip
cpython-1180e5a51871fa53ca6892e83fd2e69dc2600447.tar.gz
cpython-1180e5a51871fa53ca6892e83fd2e69dc2600447.tar.bz2
bpo-30879: os.listdir() and os.scandir() now emit bytes names when (#2634)
called with bytes-like argument.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 49e5a37..5ff18ce 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -3420,6 +3420,22 @@ class TestScandir(unittest.TestCase):
self.assertEqual(entry.path,
os.fsencode(os.path.join(self.path, 'file.txt')))
+ def test_bytes_like(self):
+ self.create_file("file.txt")
+
+ for cls in bytearray, memoryview:
+ path_bytes = cls(os.fsencode(self.path))
+ with self.assertWarns(DeprecationWarning):
+ entries = list(os.scandir(path_bytes))
+ self.assertEqual(len(entries), 1, entries)
+ entry = entries[0]
+
+ self.assertEqual(entry.name, b'file.txt')
+ self.assertEqual(entry.path,
+ os.fsencode(os.path.join(self.path, 'file.txt')))
+ self.assertIs(type(entry.name), bytes)
+ self.assertIs(type(entry.path), bytes)
+
@unittest.skipUnless(os.listdir in os.supports_fd,
'fd support for listdir required for this test.')
def test_fd(self):