Skip to content

Commit

Permalink
fix: allow os_walk to follow symlinks (#3026)
Browse files Browse the repository at this point in the history
Allows the testinfra verifier to follow symlinks in the tests
directory.

This fixes a bug described here:
#3021
  • Loading branch information
ragingpastry authored Jan 7, 2021
1 parent f86ff1f commit 66449fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/molecule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def run_command(
return result


def os_walk(directory, pattern, excludes=[]):
def os_walk(directory, pattern, excludes=[], followlinks=False):
"""Navigate recursively and retried files based on pattern."""
for root, dirs, files in os.walk(directory, topdown=True):
for root, dirs, files in os.walk(directory, topdown=True, followlinks=followlinks):
dirs[:] = [d for d in dirs if d not in excludes]
for basename in files:
if fnmatch.fnmatch(basename, pattern):
Expand Down
7 changes: 6 additions & 1 deletion src/molecule/verifier/testinfra.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ def _get_tests(self):
:return: list
"""
return sorted(
[filename for filename in util.os_walk(self.directory, "test_*.py")]
[
filename
for filename in util.os_walk(
self.directory, "test_*.py", followlinks=True
)
]
)

def schema(self):
Expand Down

0 comments on commit 66449fc

Please sign in to comment.