-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): make demo app test options
- Loading branch information
Arnault Chazareix
committed
Jan 2, 2025
1 parent
80920c8
commit 2c2caf8
Showing
4 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import string | ||
|
||
from packaging.version import Version | ||
|
||
LATEST = "@latest" | ||
|
||
|
||
def is_version_below(target: tuple[int, int], version: str) -> bool: | ||
if version == LATEST: | ||
return False | ||
# We suppose version format to be ~=version, ==version, >version, ... | ||
if version[0] in string.digits: | ||
pass | ||
elif version[1] in string.digits: | ||
version = version[1:] | ||
else: | ||
version = version[2:] | ||
|
||
version = Version(version) | ||
return version < Version(f"{target[0]}.{target[1]}") | ||
|
||
|
||
if __name__ == "__main__": | ||
assert not is_version_below((1, 22), LATEST) | ||
assert not is_version_below((1, 22), "1.22.1") | ||
assert is_version_below((1, 22), "1.19.1") | ||
assert not is_version_below((1, 22), "~=1.24") | ||
assert not is_version_below((1, 22), ">=1.24") | ||
assert is_version_below((1, 22), "~=1.20") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters