diff --git a/changes/3917.misc.md b/changes/3917.misc.md new file mode 100644 index 0000000000..53af79fc5c --- /dev/null +++ b/changes/3917.misc.md @@ -0,0 +1 @@ +Add tests to verify that the Zarr version attribute (`__version__`) is always present, is a string, and follows the expected format. \ No newline at end of file diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000000..092223418e --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,25 @@ +"""Tests for zarr._version module""" + + +def test_version_is_available() -> None: + """Test that __version__ is available and is a string.""" + from zarr import __version__ + + assert __version__ is not None + assert isinstance(__version__, str) + assert len(__version__) > 0 + + +def test_version_format() -> None: + """Test that version follows basic format.""" + from zarr import __version__ + + assert isinstance(__version__, str) + # Basic check: should contain a dot or dash + assert "." in __version__ or "-" in __version__ + + +def test_version_is_not_unknown_in_normal_case() -> None: + from zarr import __version__ + + assert __version__ != "unknown"