From 98370101e7a6f3082e859d75a0fe446926656e54 Mon Sep 17 00:00:00 2001 From: NITHIVARSHA T P Date: Mon, 20 Apr 2026 14:12:42 +0530 Subject: [PATCH 1/3] test: add tests for version info in zarr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As part of my open source journey, I contributed to the Zarr-Python project—a community-driven library for chunked, compressed N-dimensional arrays—by adding and validating tests for its version information. Following the project’s contribution guidelines, I set up a development environment, explored the codebase, and ensured my changes were clear and reviewable. My tests guarantee that the version metadata (zarr.__version__) is always present and correctly formatted, which is essential for bug reporting, compatibility checks, and reliable package releases. This aligns with Zarr’s commitment to high test coverage and robust, user-friendly development practices. --- 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 0000000000..3f35ef3c95 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,26 @@ +"""Tests for zarr._version module""" +import pytest +import importlib +import sys + + +def test_version_is_available(): + """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(): + """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(): + from zarr import __version__ + assert __version__ != "unknown" + From 00a1141015730459693d106001184be739dfd238 Mon Sep 17 00:00:00 2001 From: NITHIVARSHA T P Date: Mon, 20 Apr 2026 15:22:05 +0530 Subject: [PATCH 2/3] fix: add type annotations and apply formatting to version tests --- tests/test_version.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_version.py b/tests/test_version.py index 3f35ef3c95..092223418e 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,26 +1,25 @@ """Tests for zarr._version module""" -import pytest -import importlib -import sys -def test_version_is_available(): +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(): +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__ + assert "." in __version__ or "-" in __version__ -def test_version_is_not_unknown_in_normal_case(): +def test_version_is_not_unknown_in_normal_case() -> None: from zarr import __version__ - assert __version__ != "unknown" + assert __version__ != "unknown" From 0aa081049d7810c3e0e1c085ea614bb04d9e89f8 Mon Sep 17 00:00:00 2001 From: NITHIVARSHA T P Date: Mon, 20 Apr 2026 16:02:31 +0530 Subject: [PATCH 3/3] chore: add release note for version info tests --- changes/3917.misc.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/3917.misc.md 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