mirror of
https://github.com/lilydjwg/nvchecker
synced 2025-01-11 16:59:27 +00:00
Use pytest for sortversion tests
This commit is contained in:
parent
bace59de78
commit
bf8a4c9298
@ -13,13 +13,10 @@ from pkg_resources import parse_version
|
||||
try:
|
||||
import pyalpm
|
||||
vercmp = cmp_to_key(pyalpm.vercmp)
|
||||
vercmp_available = True
|
||||
except ImportError:
|
||||
def vercmp(k):
|
||||
raise NotImplementedError("Using vercmp but pyalpm can not be imported!")
|
||||
vercmp_available = False
|
||||
|
||||
sort_version_keys = {"parse_version": parse_version, "vercmp": vercmp}
|
||||
|
||||
if __name__ == '__main__':
|
||||
assert(parse_version("v6.0") < parse_version("6.1"))
|
||||
assert(parse_version("v6.0") > parse_version("v6.1-stable"))
|
||||
assert(vercmp("v6.0") < vercmp("v6.1-stable"))
|
||||
|
12
tests/test_sortversion.py
Normal file
12
tests/test_sortversion.py
Normal file
@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from nvchecker.sortversion import parse_version, vercmp, vercmp_available
|
||||
|
||||
def test_parse_version():
|
||||
assert parse_version("v6.0") < parse_version("6.1")
|
||||
assert parse_version("v6.0") > parse_version("v6.1-stable")
|
||||
|
||||
@pytest.mark.skipif(not vercmp_available,
|
||||
reason="needs pyalpm")
|
||||
def test_vercmp():
|
||||
assert vercmp("v6.0") < vercmp("v6.1-stable")
|
Loading…
Reference in New Issue
Block a user