Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_with_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Run tests
run: |
source venv/bin/activate
python -m pytest -n=auto --cov=imas --cov-report=term-missing --cov-report=xml:coverage.xml --cov-report=html:htmlcov --junit-xml=junit.xml
python -m pytest -n=auto --memory --ascii --hdf5 --cov=imas --cov-report=term-missing --cov-report=xml:coverage.xml --cov-report=html:htmlcov --junit-xml=junit.xml

- name: Upload coverage report ${{ matrix.python-version }}
uses: actions/upload-artifact@v4
Expand Down
20 changes: 1 addition & 19 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ def pytest_addoption(parser):
"hdf5": HDF5_BACKEND,
"mdsplus": MDSPLUS_BACKEND,
}
try:
from imas.db_entry import DBEntry
from imas_core.exception import ImasCoreBackendException
DBEntry("imas:mdsplus?path=dummy","r")
except ImasCoreBackendException as iex:
if "not available" in str(iex.message):
_BACKENDS.pop("mdsplus")


try:
Expand All @@ -102,17 +95,6 @@ def backend(pytestconfig: pytest.Config, request: pytest.FixtureRequest):
return _BACKENDS[request.param]


@pytest.fixture()
def has_imas():
return _has_imas


@pytest.fixture()
def requires_imas():
if not _has_imas:
pytest.skip("No IMAS available")


def pytest_generate_tests(metafunc):
if "ids_name" in metafunc.fixturenames:
if metafunc.config.getoption("ids"):
Expand Down Expand Up @@ -214,7 +196,7 @@ def wrapper(*args, **kwargs):


@pytest.fixture
def log_lowlevel_calls(monkeypatch, requires_imas):
def log_lowlevel_calls(monkeypatch):
"""Debugging fixture to log calls to the imas lowlevel module."""
for al_function in dir(lowlevel):
if al_function.startswith("ual_") or al_function.startswith("al"):
Expand Down
4 changes: 2 additions & 2 deletions imas/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_imas_version():


@pytest.mark.cli
def test_db_analysis(tmp_path, requires_imas):
def test_db_analysis(tmp_path):
# This only tests the happy flow, error handling is not tested
db_path = tmp_path / "test_db_analysis"
with DBEntry(f"imas:hdf5?path={db_path}", "w") as entry:
Expand All @@ -42,7 +42,7 @@ def test_db_analysis(tmp_path, requires_imas):


@pytest.mark.cli
def test_db_analysis_csv(tmp_path, requires_imas):
def test_db_analysis_csv(tmp_path):
with DBEntry(f"imas:hdf5?path={tmp_path}/entry1", "w") as entry:
eq = entry.factory.equilibrium()
eq.ids_properties.homogeneous_time = 2
Expand Down
6 changes: 3 additions & 3 deletions imas/test/test_dbentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from imas.test.test_helpers import compare_children, open_dbentry


def test_dbentry_contextmanager(requires_imas):
def test_dbentry_contextmanager():
entry = imas.DBEntry(imas.ids_defs.MEMORY_BACKEND, "test", 1, 1)
entry.create()
ids = entry.factory.core_profiles()
Expand All @@ -22,7 +22,7 @@ def test_dbentry_contextmanager(requires_imas):
assert entry2._dbe_impl is None


def test_dbentry_contextmanager_uri(tmp_path, requires_imas):
def test_dbentry_contextmanager_uri(tmp_path):
entry = imas.DBEntry(f"imas:ascii?path={tmp_path}/testdb", "w")
ids = entry.factory.core_profiles()
ids.ids_properties.homogeneous_time = 0
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_dbentry_constructor():
assert get_entry_attrs(entry) == (1, 2, 3, 4, None, 6)


def test_ignore_unknown_dd_version(monkeypatch, worker_id, tmp_path, requires_imas):
def test_ignore_unknown_dd_version(monkeypatch, worker_id, tmp_path):
entry = open_dbentry(imas.ids_defs.MEMORY_BACKEND, "w", worker_id, tmp_path)
ids = entry.factory.core_profiles()
ids.ids_properties.homogeneous_time = 0
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from imas.backends.imas_core.imas_interface import ll_interface


def test_catch_al_exception(requires_imas):
def test_catch_al_exception():
# Do something which lets the lowlevel Cython interface throw an ALException
# Ensure we can catch it:
with pytest.raises(imas.exception.ALException):
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_ids_ascii_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_data_exists():


@pytest.fixture
def test_data(requires_imas):
def test_data():
db_entry = imas.training.get_training_db_entry()
yield db_entry
db_entry.close()
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_ids_toplevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_pretty_print(ids):
assert pprint.pformat(ids) == "<IDSToplevel (IDS:gyrokinetics)>"


def test_serialize_nondefault_dd_version(requires_imas):
def test_serialize_nondefault_dd_version():
ids = IDSFactory("3.31.0").core_profiles()
fill_with_random_data(ids)
data = ids.serialize()
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_ids_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_validate_coordinate_same_as():
(None, True),
],
)
def test_validate_on_put(monkeypatch, env_value, should_validate, requires_imas):
def test_validate_on_put(monkeypatch, env_value, should_validate):
dbentry = DBEntry(MEMORY_BACKEND, "test", 1, 1)
dbentry.create()
ids = dbentry.factory.core_profiles()
Expand Down
4 changes: 1 addition & 3 deletions imas/test/test_latest_dd_autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_latest_dd_autofill(ids_name, backend, worker_id, tmp_path):
@pytest.mark.parametrize(
"serializer", [ASCII_SERIALIZER_PROTOCOL, FLEXBUFFERS_SERIALIZER_PROTOCOL]
)
def test_latest_dd_autofill_serialize(serializer, ids_name, has_imas):
def test_latest_dd_autofill_serialize(serializer, ids_name):
"""Serialize and then deserialize again all IDSToplevels"""
if serializer is None:
pytest.skip("Unsupported serializer")
Expand All @@ -64,8 +64,6 @@ def test_latest_dd_autofill_serialize(serializer, ids_name, has_imas):
ids = factory.new(ids_name)
fill_with_random_data(ids)

if not has_imas:
return # rest of the test requires an IMAS install
data = ids.serialize(serializer)

ids2 = factory.new(ids_name)
Expand Down
10 changes: 5 additions & 5 deletions imas/test/test_lazy_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def iterate(structure):
dbentry.close()


def test_lazy_load_close_dbentry(requires_imas):
def test_lazy_load_close_dbentry():
dbentry = DBEntry(MEMORY_BACKEND, "ITER", 1, 1)
dbentry.create()

Expand All @@ -109,7 +109,7 @@ def test_lazy_load_close_dbentry(requires_imas):
print(lazy_ids.time)


def test_lazy_load_readonly(requires_imas):
def test_lazy_load_readonly():
dbentry = DBEntry(MEMORY_BACKEND, "ITER", 1, 1)
dbentry.create()
run_lazy_load_readonly(dbentry)
Expand Down Expand Up @@ -151,7 +151,7 @@ def run_lazy_load_readonly(dbentry):
dbentry.close()


def test_lazy_load_no_put(requires_imas):
def test_lazy_load_no_put():
dbentry = DBEntry(MEMORY_BACKEND, "ITER", 1, 1)
dbentry.create()

Expand All @@ -169,7 +169,7 @@ def test_lazy_load_no_put(requires_imas):
dbentry.close()


def test_lazy_load_with_new_aos(requires_imas):
def test_lazy_load_with_new_aos():
dbentry = DBEntry(MEMORY_BACKEND, "ITER", 1, 1, dd_version="3.30.0")
dbentry.create()
et = dbentry.factory.edge_transport()
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_lazy_load_with_new_aos_netcdf(tmp_path):
assert len(lazy_et.model[0].ggd[0].electrons.particles.d_radial) == 0


def test_lazy_load_with_new_structure(requires_imas):
def test_lazy_load_with_new_structure():
dbentry = DBEntry(MEMORY_BACKEND, "ITER", 1, 1, dd_version="3.30.0")
dbentry.create()

Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_nbc_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_nbc_structure_to_aos(caplog):
assert caplog.record_tuples[0][:2] == ("imas.ids_convert", logging.WARNING)


def test_nbc_0d_to_1d(caplog, requires_imas):
def test_nbc_0d_to_1d(caplog):
# channel/filter_spectrometer/radiance_calibration in spectrometer visible changed
# from FLT_0D to FLT_1D in DD 3.39.0
ids = IDSFactory("3.32.0").spectrometer_visible()
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@pytest.mark.skip(reason="skipping hli test")
@pytest.mark.filterwarnings("ignore:The input coordinates to pcolormesh:UserWarning")
@pytest.mark.parametrize("snippet", course_snippets)
def test_script_execution(snippet, monkeypatch, tmp_path, requires_imas):
def test_script_execution(snippet, monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
# Prevent showing plots in a GUI
monkeypatch.delenv("DISPLAY", raising=False)
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_static_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_ids_valid_type():
assert ids_types in ({IDSType.NONE}, {IDSType.CONSTANT, IDSType.DYNAMIC})


def test_constant_ids(caplog, requires_imas):
def test_constant_ids(caplog):
ids = imas.IDSFactory().new("amns_data")
if ids.metadata.type is IDSType.NONE:
pytest.skip("IDS definition has no constant IDSs")
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_to_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@pytest.fixture
def entry(requires_imas, monkeypatch):
def entry(monkeypatch):
monkeypatch.setenv("IMAS_VERSION", "3.39.0") # Use fixed DD version
return imas.training.get_training_db_entry()

Expand Down
6 changes: 3 additions & 3 deletions imas/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_inspect():
inspect(cp.profiles_1d[1].grid.rho_tor_norm) # IDSPrimitive


def test_inspect_lazy(requires_imas):
def test_inspect_lazy():
with get_training_db_entry() as entry:
cp = entry.get("core_profiles", lazy=True)
inspect(cp)
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_idsdiffgen():
assert diff[0] == ("profiles_1d/time", -1, 0)


def test_idsdiff(requires_imas):
def test_idsdiff():
# Test the diff rendering for two sample IDSs
with get_training_db_entry() as entry:
imas.util.idsdiff(entry.get("core_profiles"), entry.get("equilibrium"))
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_get_toplevel():
assert get_toplevel(cp) is cp


def test_is_lazy_loaded(requires_imas):
def test_is_lazy_loaded():
with get_training_db_entry() as entry:
assert is_lazy_loaded(entry.get("core_profiles")) is False
assert is_lazy_loaded(entry.get("core_profiles", lazy=True)) is True
Expand Down
Loading