File: test_file_io.py

package info (click to toggle)
python-jedi 0.19.1%2Bds1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,680 kB
  • sloc: python: 28,783; makefile: 172; ansic: 13
file content (27 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from os.path import join
from jedi.file_io import FolderIO
from test.helpers import get_example_dir


def test_folder_io_walk():
    root_dir = get_example_dir('namespace_package')
    iterator = FolderIO(root_dir).walk()
    root, folder_ios, file_ios = next(iterator)
    assert {f.path for f in folder_ios} == {join(root_dir, 'ns1'), join(root_dir, 'ns2')}
    for f in list(folder_ios):
        if f.path.endswith('ns1'):
            folder_ios.remove(f)

    root, folder_ios, file_ios = next(iterator)
    assert folder_ios
    assert root.path == join(root_dir, 'ns2')
    folder_ios.clear()
    assert next(iterator, None) is None


def test_folder_io_walk2():
    root_dir = get_example_dir('namespace_package')
    iterator = FolderIO(root_dir).walk()
    root, folder_ios, file_ios = next(iterator)
    folder_ios.clear()
    assert next(iterator, None) is None