Skip to content

Commit 9d5ecb6

Browse files
author
Mathieu Bernard
authored
test_install compatible with pip >= 10
1 parent 5be8b25 commit 9d5ecb6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/test_install.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@ def test_requirements(): # pylint: disable=no-self-use
1919
This implementation is tested to be compatible with pip 9.0.1.
2020
Test stolen from stack-overflow
2121
"""
22+
try: # for pip >= 10
23+
from pip._internal.req import parse_requirements
24+
except ImportError: # for pip <= 9.0.3
25+
from pip.req import parse_requirements
26+
27+
try:
28+
session = pip.download.PipSession()
29+
except AttributeError: # for pip >= 10
30+
session = pip._internal.download.PipSession()
31+
2232
requirements_path = pathlib.Path(__file__).parents[1].joinpath(
2333
'requirements.txt')
24-
requirements = pip.req.parse_requirements(
25-
str(requirements_path), session=pip.download.PipSession())
34+
requirements = parse_requirements(str(requirements_path), session=session)
2635
requirements = [str(r.req) for r in requirements]
2736
requirements = [r for r in requirements if r != 'None']
2837
pkg_resources.require(requirements)

0 commit comments

Comments
 (0)