Exemplo n.º 1
0
def test_iterfiles(sourcedir):
    """Test file iteration."""
    assert sorted([x[1] for x in iter_files(sourcedir)]) == [
        'broken/package.json', 'buildtpl/package.json',
        'buildtpl/webpack.config.js', 'bundle/index.js', 'simple/index.js',
        'simple/package.json', 'simple/webpack.config.js'
    ]
Exemplo n.º 2
0
def test_iterpaths(sourcedir):
    """Test paths iteration."""
    # no args has same behavior as "iter_files" from above
    assert set(iter_paths(sourcedir)) == set(iter_files(sourcedir))
    # depth 2 in this case would be also the same...
    assert set(iter_paths(sourcedir, depth=2)) == set(iter_files(sourcedir))
    # ...higher depths shouldn't affect the result either
    assert set(iter_paths(sourcedir, depth=3)) == set(iter_files(sourcedir))

    # depth 0 returns itself
    assert set(iter_paths(sourcedir, depth=0)) == {(sourcedir, '.')}

    # depth 1 returns first level of files and folders
    assert {x[1]
            for x in iter_paths(sourcedir, depth=1)} == {
                'broken',
                'buildtpl',
                'bundle',
                'bundle2',
                'simple',
                'just-a-file.js',
            }