Skip to content

Commit e977994

Browse files
committed
Fix local tests on oldest supported pip version
1 parent d0db371 commit e977994

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pip_check_reqs/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,14 @@ def f(candidate, ignore_cfg=ignore_cfg):
168168
from pip._internal.req.constructors import (
169169
install_req_from_line,
170170
)
171-
candidate_path = install_req_from_line(
171+
candidate_path = install_req_from_line( # pragma: no cover
172172
candidate.requirement,
173173
).name
174174
except (ImportError, AttributeError):
175-
candidate_path = candidate
175+
try:
176+
candidate_path = candidate.name
177+
except AttributeError:
178+
candidate_path = candidate
176179

177180
if fnmatch.fnmatch(candidate_path, ignore):
178181
return True

tests/test_find_extra_reqs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_main_failure(monkeypatch, caplog, fake_opts):
8787
caplog.set_level(logging.WARN)
8888

8989
monkeypatch.setattr(find_extra_reqs, 'find_extra_reqs',
90-
lambda x: ['extra'])
90+
lambda options, requirements_filename: ['extra'])
9191

9292
with pytest.raises(SystemExit) as excinfo:
9393
find_extra_reqs.main()
@@ -146,7 +146,11 @@ def parse_args(self):
146146

147147
monkeypatch.setattr(optparse, 'OptionParser', FakeOptParse)
148148

149-
monkeypatch.setattr(find_extra_reqs, 'find_extra_reqs', lambda x: [])
149+
monkeypatch.setattr(
150+
find_extra_reqs,
151+
'find_extra_reqs',
152+
lambda options, requirements_filename: [],
153+
)
150154
find_extra_reqs.main()
151155

152156
for event in [(logging.DEBUG, 'debug'), (logging.INFO, 'info'),

0 commit comments

Comments
 (0)