-
Notifications
You must be signed in to change notification settings - Fork 38
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
ENH: Continue running doctests on failure #197
ENH: Continue running doctests on failure #197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a changelog entry for it, too?
This works beautifully, thank you!
However, I feel the behaviour may not be always desired, so having an option to opt-in/out would be nice (I'm somewhat undecided what the default should be, inclined towards making it opt-out as doctest is running everything by default rather than stopping at the first failure, but that being said it maybe a very unexpected behaviour change for the existing doctestplus users)
pytest_doctestplus/plugin.py
Outdated
def __init__( | ||
self, checker=None, verbose=None, optionflags=0, continue_on_failure=True | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: we allow 100 long lines here, please make black behave and put things on one line :)
For backward compatibility, maybe opt-in since that would introduce no behavior change? Unless no one likes the current behavior at all? |
It doesn't add more failures, just longer tracebacks, but ideally, people maintaining packages (and looking at doctest failures) are used to the idea of looking at the top of the traceback rather than the occasional red herring at the bottom. |
Thinking about this more, I am also okay with opt-out as personally I also like to see all failures in one go and try to fix as many of them as possible in the next commit, so shall we go for "opt-out" (i.e., have this automatically be enabled) unless @saimn objects? |
Either opt-in or opt-out we need to have the option which is currently not yet included in this PR. However, I would be happy to merge this as is, and start using the dev version for astroquery, which would help smoking out issues and test the actual behaviour in practice. |
opt-out seems OK (especially if doctest does that by default). |
Sounds good. I'll add in an option. Hopefully I can reuse the one that's in vanilla pytest so that people don't need to re-write an option because they added I do think some more unit tests to make sure the effects of turning it on/off would be good. I should definitely add some data dependency like: >>> import nonexistentmodule as nem
>>> a = nem.calculate_something() Anything else spring to mind? I can't promise I'll get back to this before next week. |
@effigies - gentle ping to see whether adding the option is still on your radar? My motivations are rather selfish as I would like to use this as soon as possible for astroquery. |
2f9f0f2
to
0c12016
Compare
raise ValueError( | ||
"DocTestFinder.find: name must be given when obj.__name__ doesn't exist: " | ||
f"{type(obj)!r}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flake8 was complaining in tox.
Thanks for the bump. This should be ready for review. |
I'm afraid this is not exactly what I thought we were discussing above, or at least I didn't find the way to disable the feature in e.g. the |
I see. I was aiming to reuse the flag from regular doctests. As a flag, I believe the only way to enable/disable is with I could create a new ini flag (I think I saw how to do that), but then I'm not sure if it's configurable by the CLI. Either way, this is your project, so happy to do things the way you want... |
Ah, I see. addopts would work, too, I just didn't manage to figure out how to turn it off. Would it mean we should make the feature opt-in as opposed to opt-out? |
@bsipocz As written, it is opt-in instead of opt-out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nitpicks.
I would also like to ask someone to have a double check on, as according to the tests, this indeed opt-in, but if I test it with astroquery and on a narrative docs rst file, I get the behaviour by default.
Branch is here: https://github.com/bsipocz/astroquery/tree/hacking
command: pytest docs/imcce/imcce.rst -R
traceback:
docs/imcce/imcce.rst F [100%]
======================================================= FAILURES =======================================================
_________________________________________________ [doctest] imcce.rst __________________________________________________
176 between the individual ephemerides. By default, ``epoch_nsteps = 1``,
177 which means that only a single epoch ``epoch`` will be queried.
178
179 Consider the following example, which queries ephemerides for asteroid
180 Pallas over an entire year with a time step of 1 day:
181
182 .. doctest-remote-data::
183
184 >>> from astroquery.imcce import Miriade
185 >>> Miriade.get_ephemerides('Pallas', epoch='2019-01-01',
Differences (unified diff with -expected +actual):
@@ -1,16 +1,25 @@
<Table length=365>
-target epoch RA ... DEC_rate delta_rate
- d deg ... arcsec / min km / s
-str20 float64 float64 ... float64 float64
+target epoch RA ... DEC_rate delta_rate
+ d deg ... arcsec / min km / s
+str20 float64 float64 ... float64 float64
------ -------------------- ------------------ ... ------------ ------------
-Pallas 2458484.5 200.58653041666665 ... 0.15854 -19.3678426
-Pallas 2458485.5 200.92696041666662 ... 0.16727 -19.4137911
-Pallas 2458486.5 201.2641308333333 ... 0.17613 -19.4552654
-Pallas 2458487.5 201.59797541666663 ... 0.18511 -19.4921119
-Pallas 2458488.5 201.92842624999997 ... 0.19421 -19.5241979
+Pallas 2458484.5 200.58652916666665 ... 0.15854 -19.3678428
+Pallas 2458485.5 200.92695916666662 ... 0.16727 -19.4137914
+Pallas 2458486.5 201.2641295833333 ... 0.17613 -19.4552657
+Pallas 2458487.5 201.59797416666663 ... 0.18511 -19.4921121
+Pallas 2458488.5 201.92842499999998 ... 0.19421 -19.5241982
+Pallas 2458489.5 202.25541541666664 ... 0.20344 -19.5514112
+Pallas 2458490.5 202.57887916666664 ... 0.21278 -19.5736573
+Pallas 2458491.5 202.89875 ... 0.22224 -19.5908596
+Pallas 2458492.5 203.21496166666662 ... 0.23181 -19.6029552
... ... ... ... ... ...
-Pallas 2458844.5 261.5083995833333 ... 0.029542 -2.5107101
-Pallas 2458845.5 261.8853333333333 ... 0.034077 -2.7290984
-Pallas 2458846.5 262.26158625 ... 0.038612 -2.9467484
-Pallas 2458847.5 262.63713083333334 ... 0.043144 -3.1635878
-Pallas 2458848.5 263.01193875 ... 0.047672 -3.3795661
+Pallas 2458839.5 259.61455874999996 ... 0.0069183 -1.4120195
+Pallas 2458840.5 259.99445124999994 ... 0.011429 -1.6321409
+Pallas 2458841.5 260.37381125 ... 0.015948 -1.8522381
+Pallas 2458842.5 260.75260958333325 ... 0.020475 -2.0721405
+Pallas 2458843.5 261.1308166666666 ... 0.025007 -2.2916812
+Pallas 2458844.5 261.50840124999996 ... 0.029542 -2.510709
+Pallas 2458845.5 261.885335 ... 0.034077 -2.7290973
+Pallas 2458846.5 262.26158833333335 ... 0.038612 -2.9467473
+Pallas 2458847.5 262.63713249999995 ... 0.043144 -3.1635867
+Pallas 2458848.5 263.0119404166667 ... 0.047672 -3.379565
/Users/bsipocz/munka/devel/astroquery/docs/imcce/imcce.rst:185: DocTestFailure
448 * ``ephtype``: switch between J2000 ephemerides (default) and other
449 coordinates
450 * ``refplane``: switch from equatorial coordinates (default) to
451 ecliptical coordinates
452 * ``elements``: switch to MPCORB ephemerides instead of ASTORB
453 * ``radial_velocity``: provides additional information on target's radial
454 velocity
455
456
457 >>> 1 + 1
Expected:
3
Got:
2
/Users/bsipocz/munka/devel/astroquery/docs/imcce/imcce.rst:457: DocTestFailure
Co-authored-by: Brigitta Sipőcz <b.sipocz@gmail.com>
I forgot that I used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works now as expected, thank you for the fix!
The two more minor things that are missing are a changelog entry, and mentioning the feature in the docs. I may just add them quickly, so we can use this feature straight away when trying this plugin for some of the core libraries.
Changelog and README updated. |
Thank you so much @effigies! 🎆 |
Thank you, all! |
Closes #44.
May address #188 at least somewhat.
This may need to be hooked up with an option. Interested in more test cases to check the desired behavior.
cc @bsipocz