Skip to content

Commit

Permalink
Improve test suite error messages to debug failing tests on AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 7, 2015
1 parent 3b16ce4 commit daad2b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pip_accel/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# External dependencies.
import coloredlogs
from cached_property import cached_property
from humanfriendly import coerce_boolean, compact
from humanfriendly import coerce_boolean, compact, concatenate
from pip.commands.install import InstallCommand
from pip.exceptions import DistributionNotFound

Expand Down Expand Up @@ -892,8 +892,14 @@ def find_one_file(directory, pattern):
file is matched.
"""
matches = list(find_files(directory, pattern))
assert len(matches) == 1, "Expected to match exactly one pathname!"
return matches[0]
if len(matches) == 1:
return matches[0]
elif matches:
msg = "More than one file matched %r pattern in directory %r! (matches: %s)"
raise Exception(msg % (pattern, directory, concatenate(matches)))
else:
msg = "Failed to find file matching %r pattern in directory %r! (available files: %s)"
raise Exception(msg % (pattern, directory, concatenate(find_files(directory, '*'))))


def find_files(directory, pattern):
Expand Down

0 comments on commit daad2b6

Please sign in to comment.