2019-05-25 20:48:51 +02:00
|
|
|
import pytest
|
2019-07-31 01:54:24 +02:00
|
|
|
|
2019-09-14 19:38:05 +02:00
|
|
|
from pip._internal.cli.cmdoptions import _convert_python_version
|
2019-07-31 01:54:24 +02:00
|
|
|
|
|
|
|
|
2019-05-25 20:48:51 +02:00
|
|
|
@pytest.mark.parametrize('value, expected', [
|
2019-06-09 04:37:11 +02:00
|
|
|
('', (None, None)),
|
|
|
|
('2', ((2,), None)),
|
|
|
|
('3', ((3,), None)),
|
|
|
|
('3.7', ((3, 7), None)),
|
|
|
|
('3.7.3', ((3, 7, 3), None)),
|
|
|
|
# Test strings without dots of length bigger than 1.
|
|
|
|
('34', ((3, 4), None)),
|
2019-05-25 20:48:51 +02:00
|
|
|
# Test a 2-digit minor version.
|
2019-06-09 04:37:11 +02:00
|
|
|
('310', ((3, 10), None)),
|
|
|
|
# Test some values that fail to parse.
|
|
|
|
('ab', ((), 'each version part must be an integer')),
|
|
|
|
('3a', ((), 'each version part must be an integer')),
|
|
|
|
('3.7.a', ((), 'each version part must be an integer')),
|
|
|
|
('3.7.3.1', ((), 'at most three version parts are allowed')),
|
2019-05-25 20:48:51 +02:00
|
|
|
])
|
|
|
|
def test_convert_python_version(value, expected):
|
|
|
|
actual = _convert_python_version(value)
|
2019-06-09 04:37:11 +02:00
|
|
|
assert actual == expected, 'actual: {!r}'.format(actual)
|