mirror of https://github.com/pypa/pip
Merge pull request #6538 from cjerdonek/issue-6513-freeze-requirement-error
Include more details in a pip freeze warning message
This commit is contained in:
commit
98a77a9317
|
@ -0,0 +1,2 @@
|
|||
Include more details in the log message if ``pip freeze`` can't generate a
|
||||
requirement string for a particular distribution.
|
|
@ -60,10 +60,14 @@ def freeze(
|
|||
user_only=user_only):
|
||||
try:
|
||||
req = FrozenRequirement.from_dist(dist)
|
||||
except RequirementParseError:
|
||||
except RequirementParseError as exc:
|
||||
# We include dist rather than dist.project_name because the
|
||||
# dist string includes more information, like the version and
|
||||
# location. We also include the exception message to aid
|
||||
# troubleshooting.
|
||||
logger.warning(
|
||||
"Could not parse requirement: %s",
|
||||
dist.project_name
|
||||
'Could not generate requirement for distribution %r: %s',
|
||||
dist, exc
|
||||
)
|
||||
continue
|
||||
if exclude_editable and req.editable:
|
||||
|
|
|
@ -108,12 +108,19 @@ def test_freeze_with_invalid_names(script):
|
|||
'...{}==1.0...'.format(pkgname.replace('_', '-'))
|
||||
)
|
||||
for pkgname in invalid_pkgnames:
|
||||
_check_output(
|
||||
result.stderr,
|
||||
'...Could not parse requirement: {}\n...'.format(
|
||||
pkgname.replace('_', '-')
|
||||
)
|
||||
# Check that the full distribution repr is present.
|
||||
dist_repr = '{} 1.0 ('.format(pkgname.replace('_', '-'))
|
||||
expected = (
|
||||
'...Could not generate requirement for '
|
||||
'distribution {}...'.format(dist_repr)
|
||||
)
|
||||
_check_output(result.stderr, expected)
|
||||
|
||||
# Also check that the parse error details occur at least once.
|
||||
# We only need to find one occurrence to know that exception details
|
||||
# are logged.
|
||||
expected = '...site-packages): Parse error at "...'
|
||||
_check_output(result.stderr, expected)
|
||||
|
||||
|
||||
@pytest.mark.git
|
||||
|
|
Loading…
Reference in New Issue