Skip to content

Commit

Permalink
test iter_find_files max depth
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud committed Jun 30, 2024
1 parent 9449bb4 commit 99e55b5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/test_fileutils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from boltons.fileutils import FilePerms
import os.path

from boltons import fileutils
from boltons.fileutils import FilePerms, iter_find_files


BOLTONS_PATH = os.path.dirname(os.path.abspath(fileutils.__file__))


def test_fileperms():
Expand All @@ -17,3 +23,14 @@ def test_fileperms():
assert oct(int(up)) == '0o770'

assert int(FilePerms()) == 0


def test_iter_find_files():
def _to_baseless_list(paths):
return [p.lstrip(BOLTONS_PATH) for p in paths]

assert 'fileutils.py' in _to_baseless_list(iter_find_files(BOLTONS_PATH, patterns=['*.py']))

boltons_parent = os.path.dirname(BOLTONS_PATH)
assert 'fileutils.py' in _to_baseless_list(iter_find_files(boltons_parent, patterns=['*.py']))
assert 'fileutils.py' not in _to_baseless_list(iter_find_files(boltons_parent, patterns=['*.py'], max_depth=0))

0 comments on commit 99e55b5

Please sign in to comment.