(self)
| 1940 | p = os.path.join(p, 'd') |
| 1941 | |
| 1942 | def test_walk_above_recursion_limit(self): |
| 1943 | depth = 50 |
| 1944 | os.makedirs(os.path.join(self.walk_path, *(['d'] * depth))) |
| 1945 | with infinite_recursion(depth - 5): |
| 1946 | all = list(self.walk(self.walk_path)) |
| 1947 | |
| 1948 | sub2_path = self.sub2_tree[0] |
| 1949 | for root, dirs, files in all: |
| 1950 | if root == sub2_path: |
| 1951 | dirs.sort() |
| 1952 | files.sort() |
| 1953 | |
| 1954 | d_entries = [] |
| 1955 | d_path = self.walk_path |
| 1956 | for _ in range(depth): |
| 1957 | d_path = os.path.join(d_path, "d") |
| 1958 | d_entries.append((d_path, ["d"], [])) |
| 1959 | d_entries[-1][1].clear() |
| 1960 | |
| 1961 | # Sub-sequences where the order is known |
| 1962 | sections = { |
| 1963 | "SUB1": [ |
| 1964 | (self.sub1_path, ["SUB11"], ["tmp2"]), |
| 1965 | (self.sub11_path, [], []), |
| 1966 | ], |
| 1967 | "SUB2": [self.sub2_tree], |
| 1968 | "d": d_entries, |
| 1969 | } |
| 1970 | |
| 1971 | # The ordering of sub-dirs is arbitrary but determines the order in |
| 1972 | # which sub-sequences appear |
| 1973 | dirs = all[0][1] |
| 1974 | expected = [(self.walk_path, dirs, ["tmp1"])] |
| 1975 | for d in dirs: |
| 1976 | expected.extend(sections[d]) |
| 1977 | |
| 1978 | self.assertEqual(len(all), depth + 4) |
| 1979 | self.assertEqual(sorted(dirs), ["SUB1", "SUB2", "d"]) |
| 1980 | self.assertEqual(all, expected) |
| 1981 | |
| 1982 | |
| 1983 | @unittest.skipUnless(hasattr(os, 'fwalk'), "Test needs os.fwalk()") |
nothing calls this directly
no test coverage detected