diff --git a/src/stpipe/crds_client.py b/src/stpipe/crds_client.py index dad336b4..1f6e626e 100644 --- a/src/stpipe/crds_client.py +++ b/src/stpipe/crds_client.py @@ -52,10 +52,9 @@ def get_multiple_reference_paths(parameters, reference_file_types, observatory): log.set_log_time(True) def parsfilter(record): - if not record.getMessage().strip().startswith( - "Error determining best reference for 'pars-" - ): - return True + if "Error determining best reference for 'pars-" in record.getMessage(): + return False + return True logging.getLogger("CRDS").addFilter(parsfilter) diff --git a/tests/test_crds_client.py b/tests/test_crds_client.py index 3bb3af6d..67bd4ae5 100644 --- a/tests/test_crds_client.py +++ b/tests/test_crds_client.py @@ -4,10 +4,10 @@ @pytest.mark.skip( - "CRDS logs via stderr and pytest can't capture it. " + "CRDS logs in a non-standard way, and pytest can't capture it. " "See https://github.com/pytest-dev/pytest/issues/5997" ) -def test_pars_log_filtering(capfd): +def test_pars_log_filtering(caplog): # A bogus pars- reffile will raise an exception in CRDS with pytest.raises(Exception, match="Error determining best reference"): crds_client.get_multiple_reference_paths( @@ -33,7 +33,6 @@ def test_pars_log_filtering(capfd): # https://github.com/pytest-dev/pytest/issues/5997 # So don't rely on this test passing (currently) to be actually testing what # you think it is. - captured = capfd.readouterr() assert ( - "Error determining best reference for 'pars-crunchyfrogstep'" not in captured.err + "Error determining best reference for 'pars-crunchyfrogstep'" not in caplog.text )