Repository navigation
Allow pytest 3.x to use plugin for doctests in .rst files. - #5688
Conversation
|
@mhvk - The claims is that it's v2.8.3, and even v2.4.0 is more that 3 years old, so 👍 to remove any compatibility with earlier version. |
|
I don't think we ever formally supported a version of pytest that isn't the bundled one, so removing support for older versions than we bundle is fine. |
|
OMG @mhvk, I made a note for myself to dig into As stated in this comment in 5227, either we pin pytest to 3.0.4 until pytest-dev/pytest#2118 is fixed or ignore those warnings. Is there a way for this PR to configure the CIs to use pytest 3.x to make sure everything will pass before merge? I notice that Travis CI here is still using pytest 2.8. I tested this PR (with rebase to latest master) locally using There is a failure, as shown below, but I can't tell if it is a separate issue or not. Why would "ax.format_coord()" depends on pytest version? There are also two pytest warnings, as shown below. Can we ignore this? Or somehow configure conftest.py to ignore them? |
|
@pllim - Rather than pinning pytest version number, I would suggest to update the bundled version. While I very much support the idea of removing it asap, but we need some deprecation period as it would be rather unfair with the affiliates, they may not even be pytest 3.0x compatible themselves, to remove the bundled version straight away (and thus also bumping the default pytest version...) I can open a PR for it later tonight or tomorrow. |
|
When applying this to 1.3, I still get two failures (Python 2.7): |
|
@pllim - OK, good idea to actually test whether it works on travis, so I'll merge your PR to my branch and we can check here. @bsipocz - I agree that we cannot simply unbundle pytest, but rather have to make sure it works for whatever our bundled version is. @olebole - are those failures under python2? I admit I didn't try that, though with @pllim's PR included, this will probably happen here too. |
|
Python 2.7. Just added it above. |
|
@mhvk , I killed Travis because it regressed to pytest 2.7, not the direction that we wanted: Appveyor uses 3.0.5 and sees one of the failures reported by @olebole in Python 2.7: Update: Appveyor log still shows those two pytest warnings I thought I got rid of. Maybe my solution for that does not work for Windows? |
|
What should we do now? Wait for @bsipocz to upgrade the bundled pytest to 3.x first, then rebase and remove "use system pytest" option in Appveyor and Travis? The failures in Python 2 appear to be real, at least based on Appveyor results. |
|
One good news though, the |
|
I don't think we can update the bundled version because bundling pytest is no longer properly supported (at least not in the single file method we've used until now) - see #5509. I think the correct approach is to address #5509 and un-bundle pytest, or at least we can leave it for affiliated packages but not actually use it internally for the core package. |
|
@astrofrog - Oh, right. Then we need to add a deprecation warning so affiliates will see that the previously suggested way of importing pytest from astropy is changes and they shouldn't do that any more. Can we do that in 1.3.1 or should wait for 2.0? |
|
Update: In addition to Python 2 failures, coverage also seems to be failing with some ASCII decode error, see https://travis-ci.org/astropy/astropy/jobs/191349693 |
|
I've only had a small amount of time to look at things, but I think the unicode errors (which I can reproduce locally) are because the I tried adding Not quite sure I'll get to this again today, but I do think we're on the right path at least... |
|
More update: Using system pytest in Travis CI results in inconsistent pytest version being installed. For instance, the Python 2 test uses 3.0.5 but Python 3.3 test uses 2.7. Setting |
|
@mhvk , looking at the actual doctest plugin for pytest code, I notice that the |
|
I thought I had avoided |
|
Trying to investigate a bit further, but rather hindered by finding that Strangely, just running Hmmm, it seems none of the doctests get run! See #5695. This means the remaining issues we're having with pytest 3.x are not actually related to pytest at all -- it is just that now the tests do get run again... |
|
@mhvk, I agree about the doctest not being run by default currently on master. Good catch! One easy solution to the Python 2 failure is to deliberately use However, despite this, the coverage failure is still a separate issue (it is run in Python 3). All the failures has a similar traceback, as follows: My original hope was that fixing coverage failure would also somehow fix failure in Python 2 but it seems unlikely. |
|
OK, now that you figured out why the doctests were not run, we're back to master working again. So, in current master, we need the |
|
p.s. Do need to check that EDIT: all tests pass, and travis now runs the two "standard" ones with pytest 3.x, and appveyor its python3 test. |
|
@olebole , this PR works fine on my machine (not debian though). Did you grab the latest changes to this PR and do a |
|
@olebole - that is very strange. The travis tests do show the docs being tested in all runs. Also, I just tried on my (Debian) machine, and with |
|
@pllim I checked that I use the latest version. However, I don't use git, but applied this PR to the 1.3 release (except the travis and appveyor files). Also, I added #5689 and #5646, and unconditionally import pytest in |
|
@olebole - I'm still most puzzled, thinking that just using the changes to Indeed, I just checked and it does seem to be enough locally: This does run the doctests (but with lots of deprecation warnings: the one from Could you point me to the full patch you are currently applying? |
|
@olebole , I see that some package versions are newer than what Astropy is currently supporting (e.g., matplotlib 2.0) but that should not matter, I don't think. Are you sure that distribution includes the "docs" directory? If it is not there, then the RST files won't be discovered, hence the missing doctest. Do you have a log where doctest ran successfully? EDIT: I see that you said doctest are executed without the first patch, can you please provide a link to that log? |
|
@olebole - Do the docstring doctests behave the same way as ones in the narrative docs in the rst files? |
|
@olebole , I might have found the cause. Change |
|
Aaargh! There was just one line I had to change manually by adding four chars, and promptly I failed. Thank you very much for the help! |
|
@olebole , does this also fix that "remote data" problem or is that a separate issue still? |
|
@pllim I'll check that tomorrow. |
|
@pllim - great that you found it!! And many apologies for, likely, causing this |
|
@astrofrog - are you happy with the changes? I think all is OK now, though I think it makes sense to raise a new issue that the code should be cleaned up since there still is cruft here for much older pytest versions. |
|
Although a bit hidden in this PR, I want to express how great this is to get so excellent support here. From all of you! @mhvk @astrofrog @bsipocz @pllim Thank you very much!!! |
|
Thanks! Though it definitely goes two ways -- your reports have made astropy substantially more robust! Also, more personally, again thanks as a Debian user. E.g., just a few days ago, I realiased I needed some old midas files from 20 years, which were annoyingly still in big-endian format (made on a SparcStation...). Truly wonderful that I could convert them to fits by installing |
|
Nice work everyone! |
Allow pytest 3.x to use plugin for doctests in .rst files.
With this fix, all tests, including doctests, pass even with pytest 3.x. As it is very much a copy & paste hack, please have a careful look. Also, while we're at it, should we remove the cruft for pytest <2.4? What is our minimum version?