11"""
2- Common IO tests that apply to all grid formats.
3-
4- This module tests functionality that should work across all supported formats:
5- - Basic read/write operations
6- - Format conversions and round-trips
7- - UGRID compliance
8- - Common error handling
2+ Common IO tests that apply to all grid formats. These tests make sure the
3+ same basic things work no matter which file format you start with.
94"""
105
116import pytest
5045
5146@pytest .fixture (params = IO_READ_TEST_FORMATS )
5247def grid_from_format (request ):
53- """Fixture that loads grids from all supported formats."""
48+ """Load a Grid from each supported format for parameterized tests.
49+
50+ Handles special cases (FESOM multi-file, HEALPix) and tags the grid with
51+ ``_test_format`` for easier debugging.
52+ """
5453 format_name , subpath , filename = request .param
5554
5655 if format_name == "fesom" and filename is None :
@@ -78,17 +77,24 @@ def grid_from_format(request):
7877
7978
8079class TestIOCommon :
81- """Common IO tests across all formats."""
80+ """Common IO tests across all formats. Helps catch format-specific
81+ regressions early and keep behavior consistent.
82+ """
8283
8384 def test_return_type (self , grid_from_format ):
84- """Test that all formats can be read successfully."""
85+ """Open each format and return a ux.Grid. Checks that the public API
86+ is consistent across readers.
87+ """
8588 grid = grid_from_format
8689
8790 # Basic validation
8891 assert isinstance (grid , ux .Grid )
8992
9093 def test_ugrid_compliance (self , grid_from_format ):
91- """Test that grids from all formats meet basic UGRID standards."""
94+ """Check that a loaded grid looks like a UGRID mesh. We look for
95+ required topology, coordinates, proper fill values, reasonable degree
96+ ranges, and that ``validate()`` passes.
97+ """
9298 grid = grid_from_format
9399
94100 # Basic topology and coordinate presence
@@ -118,7 +124,9 @@ def test_ugrid_compliance(self, grid_from_format):
118124 # (Not all input files have Conventions attribute, but uxarray should handle them)
119125
120126 def test_grid_properties_consistency (self , grid_from_format ):
121- """Test that all grids have consistent basic properties after loading."""
127+ """Make sure core dims and variables are present with the expected
128+ dtypes across formats. Avoid surprises for downstream code.
129+ """
122130 grid = grid_from_format
123131
124132 # Check that all grids have the essential properties
@@ -133,10 +141,10 @@ def test_grid_properties_consistency(self, grid_from_format):
133141 assert np .issubdtype (grid .node_lon .dtype , np .floating )
134142 assert np .issubdtype (grid .node_lat .dtype , np .floating )
135143
136-
137-
138144 def test_lazy_loading (self , grid_from_format ):
139- """Test that grids support lazy loading where applicable."""
145+ """Confirm a backing xarray Dataset exists (grid._ds). Keeps IO and
146+ compute lazy where supported.
147+ """
140148 grid = grid_from_format
141149
142- assert grid ._ds is not None
150+ assert grid ._ds is not None
0 commit comments