-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Reimplement reportinfo() in doctestplus extension #6423
Conversation
In pytest 3.2.0 the member `dtest` is used in the `reportinfo()` function to report the location of the test examples in the doc, but the doctestplus extension does not pass one in the constructor. Ref: pytest-dev/pytest#2651
Hi there @nicoddemus 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labelled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 If there are any issues with this message, please report them here |
Thank you @nicoddemus! I'm not sure how to test this though other than I'll locally double check the failing packages using pytest 3.2. Could you please add a changelog entry for 2.0.2? |
Yeah unless we unpin pytest on CI, but then there are other issues to tackle I think. I did test locally using:
Sure, I was under the impression reading CONTRIBUTING that only user-visible changes needed to be mentioned that's why I didn't bother. Just pushed the new entry, let me know what you think. |
Thanks, it looks good. It's good to have a changelog here as the tests and utils modules are widely used (though it's mostly under the hood) in packages that use the astropy package-template and/or astropy-helpers. |
It makes perfect sense, thanks! |
Note to self: this will be a tricky backport due to #6384, maybe best done in a PR! |
@nicoddemus - Reading through your comments on the pytest PR, I wonder whether you have a suggestion what dtest could be passed to |
But it is also the same case as https://github.com/pytest-dev/pytest/blob/master/_pytest/doctest.py#L56 . So what are we doing wrong here? 🤔 I agree with @bsipocz that the correct fix might be to actually pass in something that does not result in |
Yeah it is confusing, but you see in I managed to create and pass a optionflags = get_optionflags(self)
runner = doctest.DebugRunner(verbose=0, optionflags=optionflags,
checker=_get_checker())
parser = doctest.DocTestParser()
dtest = parser.get_doctest(text, globs, name, filename, 0) But passing a |
@nicoddemus - Thanks, this is very helpful. I'm cc-ing @drdavella as this is super useful info for his project of factoring out all the pytest related stuff from astropy to a separate package. |
That's great, glad I could help. 👍 |
In pytest 3.2.0 the member
dtest
is used in thereportinfo()
function to report the location of the test examples in the doc, but the doctestplus extension does not pass one in the constructor.@bsipocz is absolutely right when she mentions that given pytest's
DoctestItem
constructor:One assumes
dtest
can beNone
, but it appears that this has changed over the years anddtest
is always assumed to be non-None
and used in some other places, for example:I have thought about this and I think the best solution is to fix the
doctestplus
plugin inastropy
: allowingdtest
to beNone
in pytest doesn't make sense in the current code because itsruntest
method always usesself.dtest
, otherwise it wouldn't do anything.Ref: pytest-dev/pytest#2651