diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-08 14:23:28 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-08 14:23:28 (GMT) |
commit | 5f6a0b4eb26695be759cd32e49e83f38b5123ce6 (patch) | |
tree | 64b45f0d4437b0e829dfa6f7e38b4e3bfb805cba /Lib/test/test_os.py | |
parent | 44391481d7d302bbe1c9c9eb0518b6a45f21e0b9 (diff) | |
download | cpython-5f6a0b4eb26695be759cd32e49e83f38b5123ce6.zip cpython-5f6a0b4eb26695be759cd32e49e83f38b5123ce6.tar.gz cpython-5f6a0b4eb26695be759cd32e49e83f38b5123ce6.tar.bz2 |
Issue #25911: Restored support of bytes paths in os.walk() on Windows.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index ade75a5..73db39c 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -791,10 +791,10 @@ class WalkTests(unittest.TestCase): # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base - def walk(self, directory, **kwargs): + def walk(self, top, **kwargs): if 'follow_symlinks' in kwargs: kwargs['followlinks'] = kwargs.pop('follow_symlinks') - return os.walk(directory, **kwargs) + return os.walk(top, **kwargs) def setUp(self): join = os.path.join @@ -945,11 +945,10 @@ class WalkTests(unittest.TestCase): class FwalkTests(WalkTests): """Tests for os.fwalk().""" - def walk(self, directory, **kwargs): - for root, dirs, files, root_fd in os.fwalk(directory, **kwargs): + def walk(self, top, **kwargs): + for root, dirs, files, root_fd in os.fwalk(top, **kwargs): yield (root, dirs, files) - def _compare_to_walk(self, walk_kwargs, fwalk_kwargs): """ compare with walk() results. @@ -1020,6 +1019,19 @@ class FwalkTests(WalkTests): os.unlink(name, dir_fd=rootfd) os.rmdir(support.TESTFN) +class BytesWalkTests(WalkTests): + """Tests for os.walk() with bytes.""" + def walk(self, top, **kwargs): + if 'follow_symlinks' in kwargs: + kwargs['followlinks'] = kwargs.pop('follow_symlinks') + for broot, bdirs, bfiles in os.walk(os.fsencode(top), **kwargs): + root = os.fsdecode(broot) + dirs = list(map(os.fsdecode, bdirs)) + files = list(map(os.fsdecode, bfiles)) + yield (root, dirs, files) + bdirs[:] = list(map(os.fsencode, dirs)) + bfiles[:] = list(map(os.fsencode, files)) + class MakedirTests(unittest.TestCase): def setUp(self): |