bpo-27200: fix several doctests#604
bpo-27200: fix several doctests#604berkerpeksag merged 13 commits intopython:masterfrom marco-buttu:fix-issue-27200-3rd
Conversation
|
@marco-buttu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ncoghlan, @eliben, @birkenfeld, @vsajip and @bitdancer to be potential reviewers. |
bitdancer
left a comment
There was a problem hiding this comment.
I've only glanced at the non-email package stuff, and I haven't tested any of it myself, but this looks reasonable except for my one comment.
| ... msg = message_from_binary_file(f) | ||
| >>> from email.iterators import _structure | ||
| from email import message_from_binary_file | ||
| with open('../Lib/test/test_email/data/msg_16.txt', 'rb') as f: |
There was a problem hiding this comment.
This is obviously fragile. Someone added the testsetup, and presumably it worked for them when they ran it and this change would break it for them. We should compute the path relative to email.__file__. That won't work in all cases, but it will work in more cases.
There was a problem hiding this comment.
@bitdancer in the last commit I made the change you suggested me. Thank you very much for your time!
| cases where you cannot use a list. | ||
|
|
||
| This idiom would be unsafe:: | ||
| This idiom would be unsafe: |
There was a problem hiding this comment.
Wouldn't using "::" be more correct here? I understand the use of "::" is a bit inconsistent in the rest of the file, but I prefer to keep it as is if it doesn't break any doctests.
There was a problem hiding this comment.
Hi @berkerpeksag , to make the test after The quoting is compatible with UNIX shells to pass, remote_command should be defined. In order for remote_command to be defined, we need to execute this test and the next one, that is why I changed ::`` to ``:. If you want to use :: instead of :, than you have to skip the test that uses the remote_command name, but I do not see any good reason for that.
There was a problem hiding this comment.
See my comment below about skipping tests explicitly.
There was a problem hiding this comment.
Mmm, I think there is a misunderstanding here. I do not want to skip this test group, but I want it to be executed. If we skip these tests then remote_command will not be defined and the next test groups (after The quoting is compatible with UNIX shells) will fail.
There was a problem hiding this comment.
Hello @berkerpeksag, only this point is still open. Here I prefere to execute the test, because this example defines remote_command , that is used in a subsequent example. In this way all tests pass. If you want us to skip this test, we have to skip the subsequent tests that use theremote_command name. Let me know which option you prefere. Thank you very much for your time :-)
There was a problem hiding this comment.
Sorry, I forgot to comment on this earlier. Your change looks fine to me. I still need to run the tests locally.
Doc/library/ipaddress.rst
Outdated
| ... IPv4Network) | ||
|
|
||
| import ipaddress | ||
| from ipaddress import (ip_network, IPv4Address, IPv4Interface, |
There was a problem hiding this comment.
Can we use a hanging indentation to make future diffs clearer?
from ipaddress import (
ip_network, IPv4Address, IPv4Interface, IPv4Network,
)
Doc/whatsnew/3.2.rst
Outdated
| The :func:`~math.erf` function computes a probability integral or `Gaussian | ||
| error function <https://en.wikipedia.org/wiki/Error_function>`_. The | ||
| complementary error function, :func:`~math.erfc`, is ``1 - erf(x)``: | ||
| complementary error function, :func:`~math.erfc`, is ``1 - erf(x)``:: |
There was a problem hiding this comment.
I skipped the test because it can fail (on my machine I got 0.6826894921370859 instead of 0.682689492137086).
There was a problem hiding this comment.
This is not terribly important, but it would be nice to be more explicit and use something like
.. doctest::
:options: +SKIPto skip a doctest.
There was a problem hiding this comment.
Thanks @berkerpeksag :-) I have a doubt about consistency. I agree with you that in general using the doctest directive and the SKIP option is a better choice than using ::. But about consistency the PEP8 says that "Consistency within one module or function is the most important". In this file there is no one directive doctest. To skip an entire test group the :: are provided. To skip just one test inside a group, the # doctest: +SKIP comment is provided. That is why I preferred to not use the doctest directive in this case. But if you really want to use the doctest directive, I will use it. Just let me know. Thank you very much for your time!
There was a problem hiding this comment.
Thanks for the lecture, but I'm well aware of what PEP 8 says.
There was a problem hiding this comment.
@berkerpeksag I did perceive Marco as lecturing, but rather giving the context for why he had a doubt about your suggestion.
Marco: the difference here with what PEP8 is talking about is that we are now (starting from approximately last year's PyCon sprint) actually trying to execute doctests, where we've never been worried about that in the past (and the use of : and :: may have been somewhat random). So as far as skipping doctests or not, there is no true pre-existing style to follow. We ought instead to figure out what we want to do documentation wide, and do it. And I do like Berker's suggestion, since it makes it explicit. I myself can never remember which colon form does which.
There was a problem hiding this comment.
@bitdancer thank you very much for the explanation :-) I hope at the end of this task we will write some guidelines for the doctest, in order to have only one way to write them. In this commit I deindented the code in order to allign it to the doctest directive. @berkerpeksag for sure I am not able to do any lecture. If you misunderstand my question I suppose it is becose of my poor English. Sorry for that :( Thank you very much for all the time you are spending in these reviews and answering my questions :-)
|
Thanks, Marco. I'll wait for @bitdancer's approval since he requested changes to the PR earlier. |
| import email | ||
| from email import message_from_binary_file | ||
| from os.path import join, dirname | ||
| lib_dir = dirname(email.__file__).rstrip('/email') |
There was a problem hiding this comment.
rstrip is wrong here. It doesn't you do what you think it does. Intstead, apply dirname twice.
There was a problem hiding this comment.
I made the change, thanks @bitdancer :-) It was also Unix-like biased... Two independent errors in just one line :-O Thank you very much for your time and patience. These reviews are priceless :-)
|
Thanks! |
This PR partially fixes bpo-27200. Partially and not completely, because I followed the suggestion of @ezio-melotti to split the patch in several patches. This PR is the 3rd of the series. The first one was #240 and the second one #401.
To run the doctests (from the
Docdirectory):