Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Check new astropy file overwrite error message in logging test #498

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find astropy.utils.misc.NOT_OVERWRITING_MSG. This is not released yet in astropy?
If so, this test is using error_string = f"[ERROR] skypy: File {output_filename!r} already exists." unless the new astropy error message exists. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct; it's a change only on their main branch at the moment

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