From e23ce5bf01a17cc43dd2a809caa5848163b2b8ca Mon Sep 17 00:00:00 2001 From: Richard R <58728519+rrjbca@users.noreply.github.com> Date: Tue, 26 Oct 2021 11:17:14 +0100 Subject: [PATCH] Check new astropy file overwrite error message in logging test --- skypy/pipeline/tests/test_skypy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/skypy/pipeline/tests/test_skypy.py b/skypy/pipeline/tests/test_skypy.py index 2fa7b750..f84a5ea5 100644 --- a/skypy/pipeline/tests/test_skypy.py +++ b/skypy/pipeline/tests/test_skypy.py @@ -93,7 +93,14 @@ def test_logging(capsys, tmp_path): assert(f"[INFO] skypy: Writing {output_filename}" in err) # Check error for existing output file is in the log - assert(f"[ERROR] skypy: File {output_filename!r} already exists." in err) + try: + # New error message introduced in astropy PR #12179 + from astropy.utils.misc import NOT_OVERWRITING_MSG + error_string = NOT_OVERWRITING_MSG.format(output_filename) + except ImportError: + # Fallback on old error message from astropy v4.x + error_string = f"[ERROR] skypy: File {output_filename!r} already exists." + assert(error_string in err) # Run again with decreased verbosity and check the log is empty with pytest.raises(SystemExit):