Skip to content

Commit 83ca1bc

Browse files
committed
Add: Extend tests for verifying the version in Python projects
Ensure that `pontos-version verify current` works for Python projects as expected.
1 parent c4ae708 commit 83ca1bc

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

tests/version/test_python_version.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,12 @@ def test_current_version_not_equal_pyproject_toml_version(self):
258258
PythonVersionCommand,
259259
"version_file_path",
260260
new=PropertyMock(return_value=fake_version_py),
261+
), self.assertRaisesRegex(
262+
VersionError,
263+
"The version .* in .* doesn't match the current version .*.",
261264
):
262265
cmd = PythonVersionCommand()
263-
with self.assertRaisesRegex(
264-
VersionError,
265-
"The version .* in .* doesn't match the current version .*.",
266-
):
267-
cmd.verify_version(Version("1.2.3"))
266+
cmd.verify_version(Version("1.2.3"))
268267

269268
def test_current_version(self):
270269
fake_version_py = Path("foo.py")
@@ -287,6 +286,30 @@ def test_current_version(self):
287286
cmd = PythonVersionCommand()
288287
cmd.verify_version("current")
289288

289+
def test_current_failure(self):
290+
fake_version_py = Path("foo.py")
291+
content = (
292+
'[tool.poetry]\nversion = "1.2.4"\n'
293+
'[tool.pontos.version]\nversion-module-file = "foo.py"'
294+
)
295+
296+
with temp_file(
297+
content, name="pyproject.toml", change_into=True
298+
), patch.object(
299+
PythonVersionCommand,
300+
"get_current_version",
301+
MagicMock(return_value=Version("1.2.3")),
302+
), patch.object(
303+
PythonVersionCommand,
304+
"version_file_path",
305+
new=PropertyMock(return_value=fake_version_py),
306+
), self.assertRaisesRegex(
307+
VersionError,
308+
"The version .* in .* doesn't match the current version .*.",
309+
):
310+
cmd = PythonVersionCommand()
311+
cmd.verify_version("current")
312+
290313
def test_provided_version_missmatch(self):
291314
fake_version_py = Path("foo.py")
292315
content = (

0 commit comments

Comments
 (0)