BUG: warn instead of raise when failing to read specific files in fitsdiff script#18882
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
fca1854 to
def9770
Compare
|
devdeps, devinfra, and predeps failures appear unrelated |
|
Which test was failing where before? I was expecting a test to be modified to catch this added warning but I don't see it in the code and CI is green. Hope you can clarify. Thanks! |
|
the test runs as is. The reprod listed on the issue #18880 What's surprising is that it seems I discovered the issue with #18784 |
|
I think my previous hypothesis was incorrect. Rather, I now think that the important (yet, unintended) change in #18784 is the behavior of the |
|
|
|
@saimn I tentatively removed the marker. |
|
Right. Would still be useful to test that the error is properly caught and message is correctly formatted and printed. Maybe easier to do with a dedicated test using only the |
|
sure, coming right up. |
55d1452 to
ad16d47
Compare
|
test added |
|
actually I'll take another minute to polish it. Will undraft when ready |
ad16d47 to
a806ef5
Compare
| out, err = capsys.readouterr() | ||
| assert out == "" | ||
| assert err == f"Warning: failed to open {tmp} (or {Zfile}). Skipping.\n" | ||
|
|
There was a problem hiding this comment.
Thanks. To be complete, could you also test when and when b != a-q is used?
Also we could make the test independent of whether uncompresspy is installed or not by moking its import (I think this can be done applying pytest's monkeypatch on sys.modules).
There was a problem hiding this comment.
Thanks. To be complete, could you also test when b != a and when -q is used?
done. will push in a minute.
Also we could make the test independent of whether uncompresspy is installed or not by moking its import (I think this can be done applying pytest's monkeypatch on sys.modules).
I'm not sure about this; my understanding is that sys.modules reflects what modules where already imported, while HAS_UNCOMPRESSPY is only about wether the module is installed (wether or not it was already imported). Maybe I can mock the constant itself, but I've had bad experiences with mocking so I'm not confident this will work.
There was a problem hiding this comment.
what I tried:
monkeypatch.setattr(
"astropy.utils.compat.optional_deps", "HAS_UNCOMPRESSPY", False
)result:
AttributeError: 'astropy.utils.compat.optional_deps' has no attribute 'HAS_UNCOMPRESSPY'
I never quite seem to get the hang of it. I'm open to suggestions. Meanwhile, I'll push what working code I have.
There was a problem hiding this comment.
Indeed, but this seems to work (and is more targeted so probably better anyway):
monkeypatch.setattr(fits.file, "HAS_UNCOMPRESSPY", False)
There was a problem hiding this comment.
confirmed. Thank you very much !
a806ef5 to
2553087
Compare
|
Ah. My tests are failing on a warning despite it being explicitly filtered. I can only suspect this has to do with |
2553087 to
44e83c3
Compare
d370e96 to
91fc20b
Compare
|
tentatively rebased on top of #18890 |
|
that seems to do it. I'll mark that other PR as a blocker to this one then |
91fc20b to
332b65b
Compare
|
rebased to main. Should be stable now. |
… read specific files in fitsdiff script
… read specific files in fitsdiff script
… read specific files in fitsdiff script
…882-on-v7.2.x Backport PR #18882 on branch v7.2.x (BUG: warn instead of raise when failing to read specific files in fitsdiff script)
Description
Fixes #18880