1 0
import os
2 0
from ..utils import find_data_files
3

4

5 0
def test_find_data_files(tmpdir):
6

7 0
    data = tmpdir.mkdir('data')
8 0
    sub1 = data.mkdir('sub1')
9 0
    sub2 = data.mkdir('sub2')
10 0
    sub3 = sub1.mkdir('sub3')
11

12 0
    for directory in (data, sub1, sub2, sub3):
13 0
        filename = directory.join('data.dat').strpath
14 0
        with open(filename, 'w') as f:
15 0
            f.write('test')
16

17 0
    filenames = find_data_files(data.strpath, '**/*.dat')
18

19 0
    filenames = sorted(os.path.relpath(x, data.strpath) for x in filenames)
20

21 0
    assert filenames[0] == os.path.join('data.dat')
22 0
    assert filenames[1] == os.path.join('sub1', 'data.dat')
23 0
    assert filenames[2] == os.path.join('sub1', 'sub3', 'data.dat')
24 0
    assert filenames[3] == os.path.join('sub2', 'data.dat')

Read our documentation on viewing source code .

Loading