summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-15 16:30:02 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-16 06:57:01 +0200
commit256405dcfd7bc3702a72b1700ce571704596bf23 (patch)
tree3e895593b570a6490d656fa48e9eede7a3f2ff38 /script
parentef809ddc256a944f34289ef27be47655fdfa98a5 (diff)
downloadastroid-git-256405dcfd7bc3702a72b1700ce571704596bf23.tar.gz
Add test for getting the new version
Diffstat (limited to 'script')
-rw-r--r--script/bump_changelog.py7
-rw-r--r--script/test_bump_changelog.py9
2 files changed, 15 insertions, 1 deletions
diff --git a/script/bump_changelog.py b/script/bump_changelog.py
index 21deb498..dae41e3e 100644
--- a/script/bump_changelog.py
+++ b/script/bump_changelog.py
@@ -32,7 +32,12 @@ def main() -> None:
def get_next_version(version: str) -> str:
new_version = version.split(".")
- new_version[2] = str(int(new_version[2]) + 1)
+ patch = new_version[2]
+ reminder = None
+ if "-" in patch:
+ patch, reminder = patch.split("-")
+ patch = str(int(patch) + 1)
+ new_version[2] = patch if reminder is None else f"{patch}-{reminder}"
return ".".join(new_version)
diff --git a/script/test_bump_changelog.py b/script/test_bump_changelog.py
new file mode 100644
index 00000000..4e70ab16
--- /dev/null
+++ b/script/test_bump_changelog.py
@@ -0,0 +1,9 @@
+import pytest
+from bump_changelog import get_next_version
+
+
+@pytest.mark.parametrize(
+ "version,expected", [["2.6.1", "2.6.2"], ["2.6.1-dev0", "2.6.2-dev0"]]
+)
+def test_get_next_version(version, expected):
+ assert get_next_version(version) == expected