Skip to content

Commit

Permalink
Merge pull request #139 from ACCESS-NRI/137/capture-unrecognized-unit…
Browse files Browse the repository at this point in the history
…-warning

Capture filename key warning in test
  • Loading branch information
atteggiani authored Nov 7, 2024
2 parents 0ca826c + 21aeb32 commit b55e1b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions test/test_conversion_driver_esm1p5.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ def test_get_nc_write_path_unrecognized_unit():
nc_write_dir = Path("netCDF")
expected_nc_write_path = nc_write_dir / f"aiihca.p{unknown_key}-005007.nc"

nc_write_path = esm1p5_convert.get_nc_write_path(
Path(ff_name),
nc_write_dir,
(ff_year, ff_month, 1)
)
with pytest.warns(RuntimeWarning):
nc_write_path = esm1p5_convert.get_nc_write_path(
Path(ff_name),
nc_write_dir,
(ff_year, ff_month, 1)
)

assert nc_write_path == expected_nc_write_path

Expand Down
2 changes: 1 addition & 1 deletion umpost/conversion_driver_esm1p5.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_nc_filename(fields_file_name, date=None):
warnings.warn(
f"Unit code '{unit}' from filename f{fields_file_name} "
"not recognized. Frequency information will not be added "
"to the netCDF filename."
"to the netCDF filename.", RuntimeWarning
)
suffix = ""

Expand Down

0 comments on commit b55e1b1

Please sign in to comment.