Skip to content

Commit

Permalink
Check new astropy file overwrite error message in logging test (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrjbca authored Oct 26, 2021
1 parent 23db048 commit 1cc11fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion skypy/pipeline/tests/test_skypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1cc11fe

Please sign in to comment.