diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-03-23 10:24:36 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-03-26 15:55:20 +0900 |
commit | fe06d87f65aabd80724a9fed12c695d192eeb999 (patch) | |
tree | 2b86efef1f85a8ac1ca0343b42cd80da03b7a716 | |
parent | a27c56a0542388f3d2390a9f013ba21b99c854b0 (diff) |
test_requirements: Avoid using pip as library
Because importing "pip" in Python scripts is not supported usage of
"pip", this patch fixes to use "pkg_resources" + "urllib" instead.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/unit/test_requirements.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/ryu/tests/unit/test_requirements.py b/ryu/tests/unit/test_requirements.py index 9f50a518..c842a0f0 100644 --- a/ryu/tests/unit/test_requirements.py +++ b/ryu/tests/unit/test_requirements.py @@ -19,8 +19,6 @@ import sys import unittest import pkg_resources -from pip.req import parse_requirements -from pip.download import PipSession from six.moves import urllib from nose.tools import ok_ @@ -28,7 +26,7 @@ from nose.tools import ok_ LOG = logging.getLogger(__name__) -MOD_DIR = os.path.dirname(sys.modules[__name__].__file__) +MOD_DIR = os.path.dirname('file://' + sys.modules[__name__].__file__) _RYU_REQUIREMENTS_FILES = [ '../../../tools/pip-requires', '../../../tools/optional-requires', @@ -51,9 +49,10 @@ OPENSTACK_REQUIREMENTS_FILES = [ def _get_requirements(files): requirements = {} for f in files: - req = parse_requirements(f, session=PipSession()) - for r in req: - requirements[r.name] = str(r.req) + response = urllib.request.urlopen(f) + contents = response.read().decode('utf-8') + for r in pkg_resources.parse_requirements(contents): + requirements[r.name] = str(r) return requirements @@ -82,5 +81,5 @@ class TestRequirements(unittest.TestCase): except pkg_resources.VersionConflict as e: LOG.exception( 'Some requirements of Ryu are conflicting with that of ' - 'OpenStack project: %s' % OPENSTACK_REQUIREMENTS_REPO) + 'OpenStack project: %s', OPENSTACK_REQUIREMENTS_REPO) raise e |