aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core/pep440_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2024-06-01 17:17:27 +0200
committerGitHub <noreply@github.com>2024-06-01 17:17:27 +0200
commit0950b15060067f752fde13a779a994f59516ce3d (patch)
treea3ca63d8db0b590e91427f4a6bbd8e421d1e5991 /tests/mason-core/pep440_spec.lua
parentci: upgrade deps (#1726) (diff)
downloadmason-0950b15060067f752fde13a779a994f59516ce3d.tar
mason-0950b15060067f752fde13a779a994f59516ce3d.tar.gz
mason-0950b15060067f752fde13a779a994f59516ce3d.tar.bz2
mason-0950b15060067f752fde13a779a994f59516ce3d.tar.lz
mason-0950b15060067f752fde13a779a994f59516ce3d.tar.xz
mason-0950b15060067f752fde13a779a994f59516ce3d.tar.zst
mason-0950b15060067f752fde13a779a994f59516ce3d.zip
feat(pypi): improve resolving suitable python version (#1725)
Diffstat (limited to 'tests/mason-core/pep440_spec.lua')
-rw-r--r--tests/mason-core/pep440_spec.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/mason-core/pep440_spec.lua b/tests/mason-core/pep440_spec.lua
new file mode 100644
index 00000000..c8ff9880
--- /dev/null
+++ b/tests/mason-core/pep440_spec.lua
@@ -0,0 +1,22 @@
+local pep440 = require "mason-core.pep440"
+
+describe("pep440 version checking", function()
+ it("should check single version specifier", function()
+ assert.is_false(pep440.check_version("3.5.0", ">=3.6"))
+ assert.is_true(pep440.check_version("3.6.0", ">=3.6"))
+ assert.is_false(pep440.check_version("3.6.0", ">=3.6.1"))
+ end)
+
+ it("should check version specifier with lower and upper bound", function()
+ assert.is_true(pep440.check_version("3.8.0", ">=3.8,<3.12"))
+ assert.is_false(pep440.check_version("3.12.0", ">=3.8,<3.12"))
+ assert.is_true(pep440.check_version("3.12.0", ">=3.8,<4.0.0"))
+ end)
+
+ it("should check multiple specifiers with different constraints", function()
+ assert.is_false(pep440.check_version("3.5.0", "!=4.0,<=4.0,>=3.8"))
+ assert.is_false(pep440.check_version("4.0.0", "!=4.0,<=4.0,>=3.8"))
+ assert.is_true(pep440.check_version("3.8.1", "!=4.0,<=4.0,>=3.8"))
+ assert.is_true(pep440.check_version("3.12.0", "!=4.0,<=4.0,>=3.8"))
+ end)
+end)