mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 10:18:12 +00:00
version: add missing test for format_version, fix bug
This commit is contained in:
parent
12fd244801
commit
7965efd5d9
2 changed files with 17 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ..version import parse_version
|
from ..version import parse_version, format_version
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("version_str, version_tuple", [
|
@pytest.mark.parametrize("version_str, version_tuple", [
|
||||||
|
@ -36,3 +36,18 @@ def test_parse_version_invalid():
|
||||||
assert parse_version('1.2') # we require x.y.z versions
|
assert parse_version('1.2') # we require x.y.z versions
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
assert parse_version('crap')
|
assert parse_version('crap')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("version_str, version_tuple", [
|
||||||
|
('1.0.0a1', (1, 0, 0, -4, 1)),
|
||||||
|
('1.0.0', (1, 0, 0, -1)),
|
||||||
|
('1.0.0a2', (1, 0, 0, -4, 2)),
|
||||||
|
('1.0.0b3', (1, 0, 0, -3, 3)),
|
||||||
|
('1.0.0rc4', (1, 0, 0, -2, 4)),
|
||||||
|
('0.0.0', (0, 0, 0, -1)),
|
||||||
|
('0.0.11', (0, 0, 11, -1)),
|
||||||
|
('0.11.0', (0, 11, 0, -1)),
|
||||||
|
('11.0.0', (11, 0, 0, -1)),
|
||||||
|
])
|
||||||
|
def test_format_version(version_str, version_tuple):
|
||||||
|
assert format_version(version_tuple) == version_str
|
||||||
|
|
|
@ -40,7 +40,7 @@ def format_version(version):
|
||||||
while True:
|
while True:
|
||||||
part = next(it)
|
part = next(it)
|
||||||
if part >= 0:
|
if part >= 0:
|
||||||
f += str(part)
|
f.append(str(part))
|
||||||
elif part == -1:
|
elif part == -1:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue