diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-06-03 09:45:14 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2018-06-03 09:45:14 -0400 |
commit | 7068f1d4c86e6d8e705a2b77da6c5dcf6a8d7bcd (patch) | |
tree | 975edc12b8084ba08ba1f41e2c43ad1fe6c7db14 | |
parent | 68f2ffd0bec368c31201a19b326d41dba5b81495 (diff) | |
download | python-setuptools-git-7068f1d4c86e6d8e705a2b77da6c5dcf6a8d7bcd.tar.gz |
Split test into two and parameterize
-rw-r--r-- | setuptools/tests/test_glibc.py | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/setuptools/tests/test_glibc.py b/setuptools/tests/test_glibc.py index 9cb97964..0a7cac0e 100644 --- a/setuptools/tests/test_glibc.py +++ b/setuptools/tests/test_glibc.py @@ -1,37 +1,50 @@ import warnings +import pytest + from setuptools.glibc import check_glibc_version +@pytest.fixture(params=[ + "2.20", + # used by "linaro glibc", see gh-3588 + "2.20-2014.11", + # weird possibilities that I just made up + "2.20+dev", + "2.20-custom", + "2.20.1", + ]) +def two_twenty(request): + return request.param + + +@pytest.fixture(params=["asdf", "", "foo.bar"]) +def bad_string(request): + return request.param + + class TestGlibc(object): - def test_manylinux1_check_glibc_version(self): + def test_manylinux1_check_glibc_version(self, two_twenty): """ Test that the check_glibc_version function is robust against weird glibc version strings. """ - for two_twenty in ["2.20", - # used by "linaro glibc", see gh-3588 - "2.20-2014.11", - # weird possibilities that I just made up - "2.20+dev", - "2.20-custom", - "2.20.1", - ]: - assert check_glibc_version(two_twenty, 2, 15) - assert check_glibc_version(two_twenty, 2, 20) - assert not check_glibc_version(two_twenty, 2, 21) - assert not check_glibc_version(two_twenty, 3, 15) - assert not check_glibc_version(two_twenty, 1, 15) - - # For strings that we just can't parse at all, we should warn and - # return false - for bad_string in ["asdf", "", "foo.bar"]: - with warnings.catch_warnings(record=True) as ws: - warnings.filterwarnings("always") - assert not check_glibc_version(bad_string, 2, 5) - for w in ws: - if "Expected glibc version with" in str(w.message): - break - else: - # Didn't find the warning we were expecting - assert False + assert check_glibc_version(two_twenty, 2, 15) + assert check_glibc_version(two_twenty, 2, 20) + assert not check_glibc_version(two_twenty, 2, 21) + assert not check_glibc_version(two_twenty, 3, 15) + assert not check_glibc_version(two_twenty, 1, 15) + + def test_bad_versions(self, bad_string): + """ + For unparseable strings, warn and return False + """ + with warnings.catch_warnings(record=True) as ws: + warnings.filterwarnings("always") + assert not check_glibc_version(bad_string, 2, 5) + for w in ws: + if "Expected glibc version with" in str(w.message): + break + else: + # Didn't find the warning we were expecting + assert False |