Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit namespaces support #165

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
6.4 (unreleased)
================

- Nothing changed yet.

- Add PEP 440 support (implicit namespaces).
(`#160 <https://github.com/zopefoundation/zope.testrunner/issues/160>`_)

6.3.1 (2024-02-12)
==================
Expand Down
16 changes: 9 additions & 7 deletions src/zope/testrunner/find.py
Original file line number Diff line number Diff line change
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 @@ -292,13 +297,10 @@ def update_root2ext(dirname, noext, withext):

for (p, package) in test_dirs(options, {}):
for dirname, dirs, files in walk_with_symlinks(options, p):
if dirname != p and not contains_init_py(options, files):
# This is not a plausible test directory. Avoid descending
# further.
del dirs[:]
continue
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
Original file line number Diff line number Diff line change
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')
4 changes: 3 additions & 1 deletion src/zope/testrunner/tests/testrunner-edge-cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,10 @@ Post-mortem debugging of a docfile doctest failure:

Post-mortem debugging with triple verbosity

>>> sys.stdin = Input('p x\nc')
>>> sys.argv = 'test --layer samplelayers.Layer1$ -vvv -D'.split()
>>> testrunner.run_internal(defaults)
>>> try: testrunner.run_internal(defaults)
... finally: sys.stdin = real_stdin
Running tests at level 1
Running samplelayers.Layer1 tests:
Set up samplelayers.Layer1 in 0.000 seconds.
Expand Down

This file was deleted.