mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
directories: un-recurse get_files() and get_state()
These methods were previously called recursively and it seemed to cause problems in some cases. The recursive nature of these functions not bringing any notable advantage and `os.walk()` being of better style anyway, I removed that recursive nature. Hopefully fixes #421
This commit is contained in:
@@ -13,6 +13,7 @@ from pytest import raises
|
||||
from hscommon.path import Path
|
||||
from hscommon.testutil import eq_
|
||||
|
||||
from ..fs import File
|
||||
from ..directories import Directories, DirectoryState, AlreadyThereError, InvalidPathError
|
||||
|
||||
def create_fake_fs(rootpath):
|
||||
@@ -162,6 +163,20 @@ def test_get_files():
|
||||
else:
|
||||
assert not f.is_ref
|
||||
|
||||
def test_get_files_with_folders():
|
||||
# When fileclasses handle folders, return them and stop recursing!
|
||||
class FakeFile(File):
|
||||
@classmethod
|
||||
def can_handle(cls, path):
|
||||
return True
|
||||
|
||||
d = Directories()
|
||||
p = testpath['fs']
|
||||
d.add_path(p)
|
||||
files = list(d.get_files(fileclasses=[FakeFile]))
|
||||
# We have the 3 root files and the 3 root dirs
|
||||
eq_(6, len(files))
|
||||
|
||||
def test_get_folders():
|
||||
d = Directories()
|
||||
p = testpath['fs']
|
||||
|
||||
Reference in New Issue
Block a user