| 1 | from os.path import join |
| 2 | from jedi.file_io import FolderIO |
| 3 | from test.helpers import get_example_dir |
| 4 | |
| 5 | |
| 6 | def test_folder_io_walk(): |
| 7 | root_dir = get_example_dir('namespace_package') |
| 8 | iterator = FolderIO(root_dir).walk() |
| 9 | root, folder_ios, file_ios = next(iterator) |
| 10 | assert {f.path for f in folder_ios} == {join(root_dir, 'ns1'), join(root_dir, 'ns2')} |
| 11 | for f in list(folder_ios): |
| 12 | if f.path.endswith('ns1'): |
| 13 | folder_ios.remove(f) |
| 14 | |
| 15 | root, folder_ios, file_ios = next(iterator) |
| 16 | assert folder_ios |
| 17 | assert root.path == join(root_dir, 'ns2') |
| 18 | folder_ios.clear() |
| 19 | assert next(iterator, None) is None |
| 20 | |
| 21 | |
| 22 | def test_folder_io_walk2(): |
| 23 | root_dir = get_example_dir('namespace_package') |
| 24 | iterator = FolderIO(root_dir).walk() |
| 25 | root, folder_ios, file_ios = next(iterator) |
| 26 | folder_ios.clear() |
| 27 | assert next(iterator, None) is None |