File tree Expand file tree Collapse file tree
tests/unit/CodeEntropy/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from CodeEntropy import __version__
14from CodeEntropy .config .argparse import ConfigResolver
25
36
@@ -37,3 +40,13 @@ def test_build_parser_nargs_plus_parses_top_traj_file_list():
3740 args = parser .parse_args (["--top_traj_file" , "a.tpr" , "b.trr" ])
3841
3942 assert args .top_traj_file == ["a.tpr" , "b.trr" ]
43+
44+
45+ def test_version_flag_prints_installed_version_and_exits (capsys ):
46+ parser = ConfigResolver ().build_parser ()
47+
48+ with pytest .raises (SystemExit ) as exc :
49+ parser .parse_args (["--version" ])
50+
51+ assert exc .value .code == 0
52+ assert f"CodeEntropy { __version__ } " in capsys .readouterr ().out
Original file line number Diff line number Diff line change 33
44from rich .console import Console
55
6+ from CodeEntropy import __version__
7+
68
79def test_show_splash_with_citation (runner ):
810 citation = {
@@ -26,8 +28,8 @@ def test_show_splash_with_citation(runner):
2628 out = buf .getvalue ()
2729
2830 assert "Welcome to CodeEntropy" in out
29- assert "Version 1.0 " in out
30- assert "2025-01-01" in out
31+ assert f "Version { __version__ } " in out
32+ assert "Version 1.0" not in out
3133 assert "https://example.com" in out
3234 assert "This is a test abstract." in out
3335 assert "Alice Smith" in out
@@ -43,4 +45,7 @@ def test_show_splash_without_citation(runner):
4345 ):
4446 runner .show_splash ()
4547
46- assert "Welcome to CodeEntropy" in buf .getvalue ()
48+ out = buf .getvalue ()
49+
50+ assert "Welcome to CodeEntropy" in out
51+ assert f"Version { __version__ } " in out
You can’t perform that action at this time.
0 commit comments