diff --git a/src/uwtools/drivers/driver.py b/src/uwtools/drivers/driver.py index 107fd800a..dfdf80d44 100644 --- a/src/uwtools/drivers/driver.py +++ b/src/uwtools/drivers/driver.py @@ -401,7 +401,10 @@ def show_output(self): Show the output to be created by this component. """ yield self.taskname("expected output") - print(json.dumps(self.output, indent=2, sort_keys=True)) + try: + print(json.dumps(self.output, indent=2, sort_keys=True)) + except UWConfigError as e: + log.error(e) yield asset(None, lambda: True) @task diff --git a/src/uwtools/tests/drivers/test_driver.py b/src/uwtools/tests/drivers/test_driver.py index 25dd0f625..9f33c2961 100644 --- a/src/uwtools/tests/drivers/test_driver.py +++ b/src/uwtools/tests/drivers/test_driver.py @@ -457,6 +457,13 @@ def test_driver_show_output(capsys, config): assert capsys.readouterr().out.strip() == dedent(expected).strip() +def test_driver_show_output_fail(caplog, config): + with patch.object(ConcreteDriverTimeInvariant, "output", new_callable=PropertyMock) as output: + output.side_effect = UWConfigError("FAIL") + ConcreteDriverTimeInvariant(config).show_output() + assert "FAIL" in caplog.messages + + @mark.parametrize( "base_file,update_values,expected", [