Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common_helper_files
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
common_helper_files
Commits
aab2a50d
Commit
aab2a50d
authored
Apr 03, 2019
by
Jörg Stucke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added symlinks to directories
parent
5be1dcb1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
fail_safe_file_operations.py
common_helper_files/fail_safe_file_operations.py
+1
-1
dir_link
tests/data/dir_link
+2
-0
test_fail_safe_file_operations.py
tests/test_fail_safe_file_operations.py
+14
-6
No files found.
common_helper_files/fail_safe_file_operations.py
View file @
aab2a50d
...
...
@@ -221,7 +221,7 @@ def safe_rglob(path: Path, include_symlinks: bool = True, include_directories: b
def
_iterate_path_recursively
(
path
:
Path
,
include_symlinks
:
bool
=
True
,
include_directories
:
bool
=
True
):
try
:
if
path
.
is_symlink
():
if
include_symlinks
and
path
.
is_file
(
):
if
include_symlinks
and
(
path
.
is_file
()
or
path
.
is_dir
()
):
yield
path
else
:
yield
from
[]
...
...
tests/data/dir_link
0 → 120000
View file @
aab2a50d
test_folder
\ No newline at end of file
tests/test_fail_safe_file_operations.py
View file @
aab2a50d
...
...
@@ -130,19 +130,27 @@ class TestFailSafeFileOperations(unittest.TestCase):
@pytest.mark.parametrize
(
'symlinks, directories, expected_number'
,
[
(
True
,
True
,
5
),
(
False
,
True
,
4
),
(
True
,
False
,
4
),
(
True
,
True
,
7
),
(
False
,
True
,
5
),
(
True
,
False
,
5
),
(
False
,
False
,
3
),
])
def
test_safe_rglob
(
symlinks
,
directories
,
expected_number
):
test_dir_path
=
Path
(
TestFailSafeFileOperations
.
get_directory_of_current_file
())
.
parent
/
'tests'
/
'data'
result
=
safe_rglob
(
test_dir_path
,
include_symlinks
=
symlinks
,
include_directories
=
directories
)
assert
len
(
list
(
result
)
)
==
expected_number
result
=
list
(
safe_rglob
(
test_dir_path
,
include_symlinks
=
symlinks
,
include_directories
=
directories
)
)
assert
len
(
result
)
==
expected_number
def
test_safe_rglob_
no_
valid_path
():
def
test_safe_rglob_
in
valid_path
():
test_path
=
Path
(
'foo'
,
'bar'
)
assert
not
test_path
.
exists
()
result
=
safe_rglob
(
test_path
)
assert
len
(
list
(
result
))
==
0
def
test_safe_rglob_empty_dir
():
test_path
=
Path
(
TestFailSafeFileOperations
.
get_directory_of_current_file
())
.
parent
/
'tests'
/
'data'
/
'empty_folder'
assert
test_path
.
exists
()
result
=
safe_rglob
(
test_path
)
assert
len
(
list
(
result
))
==
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment