1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 17:57:59 +00:00

version: add missing test for format_version, fix bug

This commit is contained in:
Marian Beermann 2017-06-27 10:11:57 +02:00
parent 12fd244801
commit 7965efd5d9
2 changed files with 17 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import pytest
from ..version import parse_version
from ..version import parse_version, format_version
@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
with pytest.raises(ValueError):
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

View file

@ -40,7 +40,7 @@ def format_version(version):
while True:
part = next(it)
if part >= 0:
f += str(part)
f.append(str(part))
elif part == -1:
break
else: