Skip to content

Commit

Permalink
feat: ignore certain folders
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Feb 26, 2024
1 parent fff59d4 commit 4a41c25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/zope/testrunner/find.py
Expand Up @@ -25,7 +25,12 @@
from zope.testrunner.filter import build_filtering_func


identifier = re.compile(r'[_a-zA-Z]\w*$').match
identifier = re.compile(r'[_a-z]\w*$', re.I).match
IGNORE_FOLDERS = {
'.git',
'node_modules',
'__pycache__'
}


class DuplicateTestIDError(Exception):
Expand Down Expand Up @@ -293,7 +298,9 @@ def update_root2ext(dirname, noext, withext):
for (p, package) in test_dirs(options, {}):
for dirname, dirs, files in walk_with_symlinks(options, p):
root2ext = {}
dirs[:] = [d for d in dirs if identifier(d)]
dirs[:] = [
d for d in dirs if identifier(d) and d not in IGNORE_FOLDERS
]
d = os.path.split(dirname)[1]
if tests_pattern(d) and contains_init_py(options, files):
# tests directory
Expand Down
16 changes: 16 additions & 0 deletions src/zope/testrunner/tests/test_find.py
Expand Up @@ -81,3 +81,19 @@ def test_DuplicateTestIDError_message_contains_all_test_ids(self):
self.assertIn(
os.path.join('testrunner-ex', 'sampletestsl.rst'),
str(e.exception))


class TestIdentifierMatches(unittest.TestCase):
"""Test which folders are ignored by the test runner."""

def test_ignored(self):
folders = ('spaces are bad', 'dashes-bad', 'ünicodeLeading')
for name in folders:
self.assertFalse(find.identifier(name), f'{name} is accepted')

def test_accepted(self):
folders = (
'random', 'CamelCase', 'Under_scores', '_leading_scores', 'unicöde'
)
for name in folders:
self.assertTrue(find.identifier(name), f'{name} is not accepted')

0 comments on commit 4a41c25

Please sign in to comment.