handle special case pkg_name[pkg_subname]

This commit is contained in:
Chris Meyers 2016-11-29 10:17:07 -05:00
parent 25eaae5f09
commit 6c0b97675a

View File

@ -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: