summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2012-06-25 11:49:05 (GMT)
committerLarry Hastings <larry@hastings.org>2012-06-25 11:49:05 (GMT)
commitc48fe98a7c3bb48fd689088baf3fedf9da7a8c70 (patch)
tree84126650691cd047e326368655e8fe5a9bd96101 /Lib/test/test_os.py
parent2a193a818a3a1e7ea8b184a068f39277c3468598 (diff)
downloadcpython-c48fe98a7c3bb48fd689088baf3fedf9da7a8c70.zip
cpython-c48fe98a7c3bb48fd689088baf3fedf9da7a8c70.tar.gz
cpython-c48fe98a7c3bb48fd689088baf3fedf9da7a8c70.tar.bz2
Issue #15177: Added dir_fd parameter to os.fwalk().
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 62a7dad..57de993 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -741,19 +741,38 @@ class WalkTests(unittest.TestCase):
class FwalkTests(WalkTests):
"""Tests for os.fwalk()."""
- def test_compare_to_walk(self):
- # compare with walk() results
+ def _compare_to_walk(self, walk_kwargs, fwalk_kwargs):
+ """
+ compare with walk() results.
+ """
for topdown, followlinks in itertools.product((True, False), repeat=2):
- args = support.TESTFN, topdown, None, followlinks
+ d = {'topdown': topdown, 'followlinks': followlinks}
+ walk_kwargs.update(d)
+ fwalk_kwargs.update(d)
+
expected = {}
- for root, dirs, files in os.walk(*args):
+ for root, dirs, files in os.walk(**walk_kwargs):
expected[root] = (set(dirs), set(files))
- for root, dirs, files, rootfd in os.fwalk(*args):
+ for root, dirs, files, rootfd in os.fwalk(**fwalk_kwargs):
self.assertIn(root, expected)
self.assertEqual(expected[root], (set(dirs), set(files)))
+ def test_compare_to_walk(self):
+ kwargs = {'top': support.TESTFN}
+ self._compare_to_walk(kwargs, kwargs)
+
def test_dir_fd(self):
+ try:
+ fd = os.open(".", os.O_RDONLY)
+ walk_kwargs = {'top': support.TESTFN}
+ fwalk_kwargs = walk_kwargs.copy()
+ fwalk_kwargs['dir_fd'] = fd
+ self._compare_to_walk(walk_kwargs, fwalk_kwargs)
+ finally:
+ os.close(fd)
+
+ def test_yields_correct_dir_fd(self):
# check returned file descriptors
for topdown, followlinks in itertools.product((True, False), repeat=2):
args = support.TESTFN, topdown, None, followlinks