Neater test implementation based on review
This commit is contained in:
@@ -6,19 +6,19 @@ import cibuildwheel.util
|
|||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
|
VERSION_REGEX = r'([\w-]+)==([^\s]+)'
|
||||||
|
|
||||||
def get_version_from_constraint_file(package_name, constraint_file):
|
|
||||||
version_pattern = package_name + r'==([^\s]+)'
|
|
||||||
|
|
||||||
|
def get_versions_from_constraint_file(constraint_file):
|
||||||
with open(constraint_file, encoding='utf8') as f:
|
with open(constraint_file, encoding='utf8') as f:
|
||||||
constraint_file_text = f.read()
|
constraint_file_text = f.read()
|
||||||
|
|
||||||
match = re.search(version_pattern, constraint_file_text)
|
versions = {}
|
||||||
|
|
||||||
if not match:
|
for package, version in re.findall(VERSION_REGEX, constraint_file_text):
|
||||||
raise Exception("couldn't find version spec matching " + version_pattern)
|
versions[package] = version
|
||||||
|
|
||||||
return match.group(1)
|
return versions
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('python_version', ['2.7', '3.x'])
|
@pytest.mark.parametrize('python_version', ['2.7', '3.x'])
|
||||||
@@ -36,12 +36,15 @@ def test_pinned_versions(python_version):
|
|||||||
constraint_filename = 'constraints.txt'
|
constraint_filename = 'constraints.txt'
|
||||||
|
|
||||||
constraint_file = os.path.join(cibuildwheel.util.resources_dir, constraint_filename)
|
constraint_file = os.path.join(cibuildwheel.util.resources_dir, constraint_filename)
|
||||||
|
constraint_versions = get_versions_from_constraint_file(constraint_file)
|
||||||
|
|
||||||
for package in ['pip', 'setuptools', 'wheel', 'virtualenv']:
|
for package in ['pip', 'setuptools', 'wheel', 'virtualenv']:
|
||||||
env_name = 'EXPECTED_{}_VERSION'.format(package.upper())
|
env_name = 'EXPECTED_{}_VERSION'.format(package.upper())
|
||||||
build_environment[env_name] = get_version_from_constraint_file(package, constraint_file)
|
build_environment[env_name] = constraint_versions[package]
|
||||||
|
|
||||||
cibw_environment_option = ' '.join(['{}={}'.format(k, v) for k, v in build_environment.items()])
|
cibw_environment_option = ' '.join(
|
||||||
|
['{}={}'.format(k, v) for k, v in build_environment.items()]
|
||||||
|
)
|
||||||
cibw_build_option = 'cp27-*' if python_version == '2.7' else 'cp3*'
|
cibw_build_option = 'cp27-*' if python_version == '2.7' else 'cp3*'
|
||||||
|
|
||||||
# build and test the wheels
|
# build and test the wheels
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ for package_name in ['pip', 'setuptools', 'wheel']:
|
|||||||
env_name = 'EXPECTED_{}_VERSION'.format(package_name.upper())
|
env_name = 'EXPECTED_{}_VERSION'.format(package_name.upper())
|
||||||
expected_version = os.environ[env_name]
|
expected_version = os.environ[env_name]
|
||||||
|
|
||||||
print(package_name, 'version should equal', expected_version)
|
assert '{}=={}'.format(package_name, expected_version) in versions, (
|
||||||
|
'error: {} version should equal {}'.format(package_name, expected_version)
|
||||||
assert '{}=={}'.format(package_name, expected_version) in versions
|
)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="spam",
|
name="spam",
|
||||||
|
|||||||
Reference in New Issue
Block a user