From 2fdb9893604e34166cf38920a99df52f4ef539bc Mon Sep 17 00:00:00 2001 From: figsoda Date: Wed, 26 Apr 2023 23:24:38 -0400 Subject: [PATCH] improve version assertions in tests fixes broken tests due to flaky string comparisons --- tests/test_flake.py | 2 +- tests/test_gitea.py | 2 +- tests/test_github.py | 2 +- tests/test_gitlab.py | 2 +- tests/test_npm.py | 4 ++-- tests/test_pypi.py | 2 +- tests/test_savanna.py | 4 ++-- tests/test_sourcehut.py | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test_flake.py b/tests/test_flake.py index 6f10da1..247ff17 100644 --- a/tests/test_flake.py +++ b/tests/test_flake.py @@ -21,7 +21,7 @@ def test_main(helpers: conftest.Helpers) -> None: text=True, stdout=subprocess.PIPE, ).stdout.strip() - assert version >= "8.5.2" + assert tuple(map(int, version.split("."))) >= (8, 5, 2) commit = subprocess.run( ["git", "-C", path, "log", "-1"], text=True, diff --git a/tests/test_gitea.py b/tests/test_gitea.py index e52c701..e4e1f0c 100644 --- a/tests/test_gitea.py +++ b/tests/test_gitea.py @@ -23,7 +23,7 @@ def test_main(helpers: conftest.Helpers) -> None: text=True, stdout=subprocess.PIPE, ).stdout.strip() - assert version >= "30" + assert int(version) >= 30 commit = subprocess.run( ["git", "-C", path, "log", "-1"], text=True, diff --git a/tests/test_github.py b/tests/test_github.py index ee7aace..7911fab 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -23,7 +23,7 @@ def test_main(helpers: conftest.Helpers) -> None: text=True, stdout=subprocess.PIPE, ).stdout.strip() - assert version >= "8.5.2" + assert tuple(map(int, version.split("."))) >= (8, 5, 2) commit = subprocess.run( ["git", "-C", path, "log", "-1"], text=True, diff --git a/tests/test_gitlab.py b/tests/test_gitlab.py index c374506..6c5733c 100644 --- a/tests/test_gitlab.py +++ b/tests/test_gitlab.py @@ -23,7 +23,7 @@ def test_main(helpers: conftest.Helpers) -> None: text=True, stdout=subprocess.PIPE, ).stdout.strip() - assert version >= "0.22.0" + assert tuple(map(int, version.split("."))) >= (0, 22, 0) commit = subprocess.run( ["git", "-C", path, "log", "-1"], text=True, diff --git a/tests/test_npm.py b/tests/test_npm.py index 9d742df..c718e0c 100644 --- a/tests/test_npm.py +++ b/tests/test_npm.py @@ -23,5 +23,5 @@ def test_update(helpers: conftest.Helpers) -> None: ], text=True, stdout=subprocess.PIPE, - ) - assert version.stdout.strip() > "10.8.6" + ).stdout.strip() + assert tuple(map(int, version.split("."))) > (10, 8, 6) diff --git a/tests/test_pypi.py b/tests/test_pypi.py index 0ad1ce8..1d8442c 100644 --- a/tests/test_pypi.py +++ b/tests/test_pypi.py @@ -23,7 +23,7 @@ def test_main(helpers: conftest.Helpers) -> None: text=True, stdout=subprocess.PIPE, ).stdout.strip() - assert version >= "3.0.1" + assert tuple(map(int, version.split("."))) >= (3, 0, 1) commit = subprocess.run( ["git", "-C", path, "log", "-1"], text=True, diff --git a/tests/test_savanna.py b/tests/test_savanna.py index e613501..042b8a6 100644 --- a/tests/test_savanna.py +++ b/tests/test_savanna.py @@ -23,5 +23,5 @@ def test_update(helpers: conftest.Helpers) -> None: ], text=True, stdout=subprocess.PIPE, - ) - assert version.stdout.strip() >= "0.6.8" + ).stdout.strip() + assert tuple(map(int, version.split("."))) >= (0, 6, 8) diff --git a/tests/test_sourcehut.py b/tests/test_sourcehut.py index af4b375..930ea6c 100644 --- a/tests/test_sourcehut.py +++ b/tests/test_sourcehut.py @@ -23,5 +23,5 @@ def test_update(helpers: conftest.Helpers) -> None: ], text=True, stdout=subprocess.PIPE, - ) - assert version.stdout.strip() >= "0.3.6" + ).stdout.strip() + assert tuple(map(int, version.split("."))) >= (0, 3, 6)