diff --git a/awx/main/tests/functional/test_python_requirements.py b/awx/main/tests/functional/test_python_requirements.py index 7c5f671e78..0dc48f66b8 100644 --- a/awx/main/tests/functional/test_python_requirements.py +++ b/awx/main/tests/functional/test_python_requirements.py @@ -1,5 +1,6 @@ import os +import re from pip.operations import freeze from django.conf import settings @@ -16,23 +17,34 @@ def test_env_matches_requirements_txt(): requirements_path = os.path.join(base_dir, '../', 'requirements/requirements.txt') reqs_actual = [] - xs = freeze.freeze(local_only=True, requirement=requirements_path) + xs = freeze.freeze(local_only=True) for x in xs: if '## The following requirements were added by pip freeze' in x: break - reqs_actual.append(x.split('==')) + x = x.lower() + (pkg_name, pkg_version) = x.split('==') + reqs_actual.append([pkg_name, pkg_version]) reqs_expected = [] with open(requirements_path) as f: for line in f: - line.rstrip() + line = line.partition('#')[0] + line = line.rstrip().lower() # TODO: process git requiremenst and use egg + if line == '': + continue if line.strip().startswith('#') or line.strip().startswith('git'): continue if line.startswith('-e'): continue - line.rstrip() - reqs_expected.append(line.rstrip().split('==')) + + ''' + Special case pkg_name[pkg_subname]==version + For this case, we strip out [pkg_subname] + ''' + (pkg_name, pkg_version) = line.split('==') + pkg_name = re.sub(r'\[.*\]', '', pkg_name) + reqs_expected.append([pkg_name, pkg_version]) not_found = [] for r in reqs_expected: