Skip to content

Conversation

@cmarmo
Copy link
Member

@cmarmo cmarmo commented Dec 6, 2020

Description

This pull request removes the .. doctest-skip directive from the FITS verification page. I could not find a better way to manage warnings than inserting a doctest.IGNORE_EXCEPTION_DETAIL.

Fixes #6686.

Copy link
Contributor

@saimn saimn left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @cmarmo, very useful since obviously some examples were out of date. I'm not sure how to best handle the warnings/exception issue (some ideas in the comments). It would be better if the users can see the warnings as they would get them by default.

@pllim
Copy link
Member

pllim commented Dec 8, 2020

Re: Warnings -- If you want them to show but don't want doctest to fail, use https://github.com/astropy/pytest-doctestplus#ignoring-warnings

# doctest: +IGNORE_WARNINGS

p.s. If you do this, don't have to write out the warnings in expected outputs.

@saimn
Copy link
Contributor

saimn commented Dec 9, 2020

@pllim - IGNORE_WARNINGS is to hide the warning isn't it ? I would see to see it, since that's the result of the FITS verification.

@pllim
Copy link
Member

pllim commented Dec 9, 2020

Yes, correct that IGNORE_WARNINGS does hide it... 🤔

@cmarmo
Copy link
Member Author

cmarmo commented Dec 9, 2020

Thanks @saimn and @pllim for your suggestions. I have recorded the warnings and printed them: note that one of the warnings is thrown as an exception by default, I've kept the IGNORE_EXCEPTION_DETAIL directive for that one. I'm not sure this is the most readable solution...

@cmarmo
Copy link
Member Author

cmarmo commented Dec 9, 2020

I've tried to clean a bit, but now to avoid ResourceWarning: unclosed file _io.FileIO warnings all fits files should be closed.

@saimn
Copy link
Contributor

saimn commented Dec 11, 2020

@cmarmo : I've hijacked a bit your PR, sorry, trying to find a better solution for warnings. To keep the docs clear and focused on the initial topic, it would be better if we could avoid all the warnings related code. So currently I have factored the catching and printing in a showwarnings context manager, which works well. And then I think we could move this to pytest-doctestplus in a new doctest flag.

@cmarmo
Copy link
Member Author

cmarmo commented Dec 11, 2020

@cmarmo : I've hijacked a bit your PR, sorry, trying to find a better solution for warnings. To keep the docs clear and focused on the initial topic, it would be better if we could avoid all the warnings related code. So currently I have factored the catching and printing in a showwarnings context manager, which works well.

@saimn no problem, this kind of refactoring was above my python skills... always happy to learn... :)

And then I think we could move this to pytest-doctestplus in a new doctest flag.

Do you mind if I add a comment in the testsetup block, to document that the function is accessory to the warning management in the example? and that it could one day be replaced by a SHOW_WARNING options?

@saimn
Copy link
Contributor

saimn commented Dec 11, 2020

Do you mind if I add a comment in the testsetup block, to document that the function is accessory to the warning management in the example? and that it could one day be replaced by a SHOW_WARNING options?

@cmarmo - I managed to make a PR on doctestplus (scientific-python/pytest-doctestplus#136), so if you don't mind waiting a bit we can update the PR once it's merged and released ? (hopefully soon!)

@cmarmo
Copy link
Member Author

cmarmo commented Dec 13, 2020

update the PR once it's merged and released ?

Arrgggh, I should have waited for the release too... :(

@saimn saimn closed this Jan 15, 2021
@saimn saimn reopened this Jan 15, 2021
@saimn
Copy link
Contributor

saimn commented Jan 15, 2021

I released the new version of pytest-doctestplus, and closed/reopened the PR to trigger the actions builds.

Copy link
Contributor

@saimn saimn left a comment

Choose a reason for hiding this comment

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

Seems all good now with the new doctestplus version. Thanks @cmarmo !

@saimn saimn merged commit 4f2c65a into astropy:master Jan 15, 2021
@cmarmo
Copy link
Member Author

cmarmo commented Jan 15, 2021

Thank you @saimn .

@cmarmo cmarmo deleted the doc-verification branch January 15, 2021 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FITS verification documentation is still untested

3 participants