diff --git a/changelog/447.trivial.rst b/changelog/447.trivial.rst new file mode 100644 index 00000000..9f819e26 --- /dev/null +++ b/changelog/447.trivial.rst @@ -0,0 +1 @@ +Fix failure to fetch CLI options in publish build. diff --git a/conftest.py b/conftest.py index 261eef90..72f242cd 100644 --- a/conftest.py +++ b/conftest.py @@ -1,3 +1,5 @@ +import warnings + import matplotlib as mpl import pytest @@ -28,8 +30,13 @@ def pytest_report_header(config, start_path): def pytest_runtest_makereport(item, call): report = yield if report.when == "call": - ds = item.config.getoption("--ds") - tds = item.config.getoption("--tiled-ds") + try: + ds = item.config.getoption("--ds") + tds = item.config.getoption("--tiled-ds") + except ValueError: + # If CLI arguments can't be found, need to return gracefully + warnings.warn("--ds and --tiled-ds were not found. Any supplied datasets were not used.") + return report if ds and item.get_closest_marker("accept_cli_dataset"): report.nodeid += f"[{ds}]" if tds and item.get_closest_marker("accept_cli_tiled_dataset"): diff --git a/dkist/conftest.py b/dkist/conftest.py index 0f8b7c9b..9d6f648b 100644 --- a/dkist/conftest.py +++ b/dkist/conftest.py @@ -1,5 +1,6 @@ import copy import gzip +import warnings from pathlib import Path import dask.array as da @@ -351,17 +352,23 @@ def visp_dataset_no_headers(tmp_path_factory): @pytest.hookimpl(hookwrapper=True) def pytest_runtest_call(item): - ds = item.config.getoption("--ds") - tds = item.config.getoption("--tiled-ds") - - # Only one of accept_cli_dataset and accept_cli_tiled_dataset should be available - mark = item.get_closest_marker("accept_cli_dataset") or item.get_closest_marker("accept_cli_tiled_dataset") - if mark: - # Replace either the fixture specified as the first arg of the marker, or the first fixture in the test definition - replace_arg = mark.args[0] if mark.args else item.fixturenames[0] - if ds: - item.funcargs[replace_arg] = load_dataset(ds) - if tds: - item.funcargs[replace_arg] = load_dataset(tds) - - yield item + try: + ds = item.config.getoption("--ds") + tds = item.config.getoption("--tiled-ds") + + # Only one of accept_cli_dataset and accept_cli_tiled_dataset should be available + mark = item.get_closest_marker("accept_cli_dataset") or item.get_closest_marker("accept_cli_tiled_dataset") + if mark: + # Replace either the fixture specified as the first arg of the marker, or the first fixture in the test definition + replace_arg = mark.args[0] if mark.args else item.fixturenames[0] + if ds: + item.funcargs[replace_arg] = load_dataset(ds) + if tds: + item.funcargs[replace_arg] = load_dataset(tds) + + yield item + except ValueError: + # If CLI arguments can't be found, need to return gracefully + # TODO raise a warning here + warnings.warn("--ds and --tiled-ds were not found. Any supplied datasets will not be used.") + yield item