From 9d608704397d8dc0fcee64fe38c90349f6a59c2b Mon Sep 17 00:00:00 2001 From: Aviad Shiber Date: Fri, 15 May 2026 19:12:39 +0300 Subject: [PATCH] test: guard against __version__ vs pyproject.toml drift PR #88 (v0.11.0) bumped pyproject.toml but left src/java_functional_lsp/__init__.py at 0.10.0, shipping a package whose --version disagreed with its installed metadata. v0.11.1 synced them. This test reads both values and asserts they match, so the next bump that touches only one side fails CI before it ships. Co-Authored-By: Claude Opus 4.7 --- tests/test_version.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/test_version.py diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..2132da2 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,26 @@ +"""Regression guard: __version__ in src must equal pyproject.toml's project.version. + +PR #88 (v0.11.0) bumped pyproject.toml to 0.11.0 but left __init__.py at 0.10.0, +shipping a package whose --version output disagreed with its metadata. v0.11.1 +hotfixed it. This test prevents the same drift from recurring. +""" + +from __future__ import annotations + +import re +from pathlib import Path + +from java_functional_lsp import __version__ + +PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml" + + +def test_version_matches_pyproject() -> None: + text = PYPROJECT.read_text() + match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', text) + assert match is not None, f"pyproject.toml at {PYPROJECT} has no top-level version line" + pyproject_version = match.group(1) + assert __version__ == pyproject_version, ( + f"java_functional_lsp.__version__={__version__!r} disagrees with " + f"pyproject.toml version={pyproject_version!r}. Update both when bumping." + )