Skip to content

Commit dec2cb5

Browse files
HarperZ9claude
andcommitted
test: version assertions read the real version, not a pinned literal
Bumping to 2.10.0 broke three tests that hardcoded the version string. Read index_graph.__version__ (and assert semver) so a version bump never breaks the build again. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 220d1c0 commit dec2cb5

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

tests/test_cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77

88
def test_version_flag_exits_zero(capsys):
9+
import index_graph
10+
911
with pytest.raises(SystemExit) as exc:
1012
main(["--version"])
1113
assert exc.value.code == 0
12-
assert "2.9.0" in capsys.readouterr().out
14+
# Assert the CLI reports the real package version, not a pinned literal.
15+
assert index_graph.__version__ in capsys.readouterr().out
1316

1417

1518
def test_json_to_stdout(tmp_path, capsys):

tests/test_version.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import re
2+
13
import index_graph
24

35

4-
def test_version_is_2_8_0():
5-
assert index_graph.__version__ == "2.9.0"
6+
def test_version_is_semver():
7+
# Read the real version rather than pin a literal: the string is bumped every
8+
# release and a hardcoded assertion just breaks the build on the bump commit.
9+
assert re.fullmatch(r"\d+\.\d+\.\d+", index_graph.__version__)

tests/test_viz_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ def test_existing_commands_unaffected(workspace, tmp_path, capsys):
7777
assert json.loads(capsys.readouterr().out) # still valid JSON
7878

7979

80-
def test_version_is_2_8_0():
80+
def test_version_is_semver():
81+
import re
82+
8183
from index_graph import __version__
82-
assert __version__ == "2.9.0"
84+
assert re.fullmatch(r"\d+\.\d+\.\d+", __version__)
8385

8486

8587
def test_all_format_no_external_is_consistent(workspace_with_external, tmp_path):

0 commit comments

Comments
 (0)