Skip to content

Commit df09558

Browse files
Copilotilaflott
andauthored
address code review: move imports to top-level, add explicit table_info/table_id assertions
Agent-Logs-Url: https://github.com/ilaflott/fremorizer/sessions/fcd4078a-1b4b-471f-b478-83f5ce1d1628 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
1 parent 09dd891 commit df09558

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

fremorizer/tests/test_cmor_run_subtool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pytest
1515

1616
from fremorizer import cmor_run_subtool
17+
from fremorizer.tests.conftest import _CMIP6_EXP_CONFIG_DATA
1718

1819

1920
# where are we? we're running pytest from the base directory of this repo
@@ -378,7 +379,6 @@ def test_exp_config_cleanup():
378379
session-scoped conftest fixture — so we rewrite it from the canonical
379380
fixture data instead of running ``git restore``.
380381
'''
381-
from fremorizer.tests.conftest import _CMIP6_EXP_CONFIG_DATA # pylint: disable=import-outside-toplevel
382382
Path(EXP_CONFIG).write_text(json.dumps(_CMIP6_EXP_CONFIG_DATA, indent=4))
383383

384384
def test_cmor_run_subtool_raise_value_error():

fremorizer/tests/test_cmor_run_subtool_cmip7.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ def _assert_metadata_matches(ds_in, ds_out):
9797
assert required_attr in ds_out.ncattrs(), \
9898
f"CMOR output missing required global attribute '{required_attr}'"
9999

100+
# CMIP7 uses 'table_info' instead of 'table_id'
101+
assert 'table_info' in ds_out.ncattrs(), \
102+
"CMOR output missing 'table_info' attribute (CMIP7-specific)"
103+
assert 'table_id' not in ds_out.ncattrs(), \
104+
"CMOR output should not have 'table_id' for CMIP7 (uses 'table_info' instead)"
105+
100106
# science variable standard_name and long_name must be preserved
101107
assert ds_in.variables['sos'].standard_name == ds_out.variables['sos'].standard_name, \
102108
"sos standard_name differs between input and CMOR output"

fremorizer/tests/test_cmor_run_subtool_further_examples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from datetime import date
66
import glob
7+
import json
78
import os
89
from pathlib import Path
910
import shutil
@@ -12,6 +13,7 @@
1213
import pytest
1314

1415
from fremorizer import cmor_run_subtool
16+
from fremorizer.tests.conftest import _CMIP6_EXP_CONFIG_DATA
1517

1618

1719
# global consts for these tests, with no/trivial impact on the results
@@ -185,6 +187,4 @@ def test_exp_config_cleanup():
185187
session-scoped conftest fixture — so we rewrite it from the canonical
186188
fixture data instead of running ``git restore``.
187189
'''
188-
import json # pylint: disable=import-outside-toplevel
189-
from fremorizer.tests.conftest import _CMIP6_EXP_CONFIG_DATA # pylint: disable=import-outside-toplevel
190190
Path(EXP_CONFIG_DEFAULT).write_text(json.dumps(_CMIP6_EXP_CONFIG_DATA, indent=4))

0 commit comments

Comments
 (0)