Skip to content

Commit

Permalink
Move sorting to different location
Browse files Browse the repository at this point in the history
  • Loading branch information
do3cc committed Dec 18, 2014
1 parent 4330ad8 commit 80e5477
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/zope/testrunner/find.py
Expand Up @@ -171,13 +171,8 @@ def find_tests(options, found_suites=None):


def find_suites(options):
# Sort prefixes so that longest prefixes come first.
# That is because only first match is evaluated which
# can be a problem with nested source packages.
sorted_prefixes = [x for x in options.prefix]
sorted_prefixes.sort(key=lambda prefix: len(prefix[0]), reverse=True)
for fpath, package in find_test_files(options):
for (prefix, prefix_package) in sorted_prefixes:
for (prefix, prefix_package) in options.prefix:
if fpath.startswith(prefix) and package == prefix_package:
# strip prefix, strip .py suffix and convert separator to dots
noprefix = fpath[len(prefix):]
Expand Down
6 changes: 6 additions & 0 deletions src/zope/testrunner/options.py
Expand Up @@ -624,6 +624,12 @@ def apply_auto_progress(args):

options.prefix = [(path + os.path.sep, package)
for (path, package) in options.test_path]

# Sort prefixes so that longest prefixes come first.
# That is because only first match is evaluated which
# can be a problem with nested source packages.
options.prefix.sort(key=lambda p: len(p[0]), reverse=True)

if options.all:
options.at_level = sys.maxsize

Expand Down

0 comments on commit 80e5477

Please sign in to comment.