Esempio n. 1
0
def test_fnwalk_shallow(mock_scandir):
    """
    Given a base path and matcher function, when fnwalk() is called with sallow
    flag, then it returns an iterator that yields only the first path matched.
    """
    matcher = lambda p: 'article' in p
    assert list(sorted(mod.fnwalk('.', matcher, shallow=True))) == [
        './articles',
    ]
Esempio n. 2
0
def test_fnwalk(mock_scandir):
    """
    Given base path and a matcher function, when fnwalk() is called, it returns
    an iterator that yields paths for which matcher returns True.
    """
    matcher = lambda p: 'article' in p
    assert list(sorted(mod.fnwalk('.', matcher))) == [
        './articles',
        './articles/article1.html',
        './articles/article2.html',
        './articles/images',
        './articles/images/img1.svg',
        './articles/images/img2.jpg',
    ]
Esempio n. 3
0
def test_fnwalk_match_self(mock_scandir):
    """
    Given a base path and matcher function that matches the base path, when
    fnwalk() is called, it returns an iterator that yields base path, in
    additon to other matched path.
    """
    matcher = lambda p: 'article' in p
    assert list(sorted(mod.fnwalk('articles', matcher))) == [
        'articles',
        'articles/article1.html',
        'articles/article2.html',
        'articles/images',
        'articles/images/img1.svg',
        'articles/images/img2.jpg',
    ]