Skip to content

Commit

Permalink
Add another check to test_combine_gridcell_files().
Browse files Browse the repository at this point in the history
  • Loading branch information
samsrabin committed Oct 15, 2024
1 parent ae15b23 commit c7dbb53
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions python/ctsm/test/test_sys_hillslopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,30 @@ def test_combine_gridcell_files(self):
outdir_chunkfiles = os.path.join(self._outdir, "chunk_files_out")
self._combine_gridcell_files(verbose=True, outdir=outdir_chunkfiles)

# Compare to expected outputs
# Make sure every output file matches its counterpart in the comparison directory
comparison_dir = os.path.join(self._testinputs_hills_path, "chunk_files")
output_files = glob.glob(os.path.join(outdir_chunkfiles, "*.nc"))
output_files.sort()
for output_file in output_files:
comparison_file = os.path.join(
os.path.join(self._testinputs_hills_path, "chunk_files"),
comparison_dir,
os.path.basename(output_file),
)
output_ds = xr.open_dataset(output_file)
comparison_ds = xr.open_dataset(comparison_file)
xr.testing.assert_equal(output_ds, comparison_ds)

# Make sure the output directory contains every expected file
comparison_files = glob.glob(os.path.join(comparison_dir, "*.nc"))
comparison_files.sort()
for comparison_file in comparison_files:
output_file = os.path.join(
outdir_chunkfiles,
os.path.basename(comparison_file),
)
if not os.path.exists(output_file):
raise RuntimeError(f"Expected output file not found: '{output_file}'")

def test_combine_chunk_files(self):
"""
Tests combine_chunk_files
Expand Down

0 comments on commit c7dbb53

Please sign in to comment.