Skip to content

Commit

Permalink
bpo-34962: make doctest in Doc/ now passes, and is enforced in CI (GH…
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixise authored and JulienPalard committed Oct 12, 2018
1 parent 53ebf4b commit 859c068
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 73 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ matrix:
- cd Doc
# Sphinx is pinned so that new versions that introduce new warnings won't suddenly cause build failures.
# (Updating the version is fine as long as no warnings are raised by doing so.)
# The theme used by the docs is stored seperately, so we need to install that as well.
- python -m pip install sphinx~=1.6.1 blurb python-docs-theme
# The theme used by the docs is stored separately, so we need to install that as well.
- python -m pip install sphinx blurb python-docs-theme
script:
- make check suspicious html SPHINXOPTS="-q -W -j4"
- os: osx
Expand Down Expand Up @@ -155,8 +155,14 @@ script:
# Check that all symbols exported by libpython start with "Py" or "_Py"
- make smelly
# `-r -w` implicitly provided through `make buildbottest`.
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then XVFB_RUN=xvfb-run; fi; $XVFB_RUN make buildbottest TESTOPTS="-j4 -uall,-cpu"

- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
XVFB_RUN=xvfb-run;
fi
$XVFB_RUN make buildbottest TESTOPTS="-j4 -uall,-cpu"
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
$XVFB_RUN make PYTHON=../python SPHINXOPTS="-q -W -j4" -C Doc/ venv doctest
fi
notifications:
email: false
webhooks:
Expand Down
7 changes: 7 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
'pyspecific', 'c_annotations', 'escape4chm']


doctest_global_setup = '''
try:
import _tkinter
except ImportError:
_tkinter = None
'''
# General substitutions.
project = 'Python'
copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y')
Expand Down
2 changes: 1 addition & 1 deletion Doc/distutils/examples.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _examples:
.. _distutils_examples:

********
Examples
Expand Down
7 changes: 4 additions & 3 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -621,18 +621,19 @@ The :mod:`multiprocessing` package mostly replicates the API of the
Example usage of some of the methods of :class:`Process`:

.. doctest::
:options: +ELLIPSIS

>>> import multiprocessing, time, signal
>>> p = multiprocessing.Process(target=time.sleep, args=(1000,))
>>> print(p, p.is_alive())
<Process(Process-1, initial)> False
<Process(..., initial)> False
>>> p.start()
>>> print(p, p.is_alive())
<Process(Process-1, started)> True
<Process(..., started)> True
>>> p.terminate()
>>> time.sleep(0.1)
>>> print(p, p.is_alive())
<Process(Process-1, stopped[SIGTERM])> False
<Process(..., stopped[SIGTERM])> False
>>> p.exitcode == -signal.SIGTERM
True

Expand Down
13 changes: 6 additions & 7 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1234,9 +1234,7 @@ Checking for a Pair
^^^^^^^^^^^^^^^^^^^

In this example, we'll use the following helper function to display match
objects a little more gracefully:

.. testcode::
objects a little more gracefully::

def displaymatch(match):
if match is None:
Expand Down Expand Up @@ -1269,10 +1267,9 @@ To match this with a regular expression, one could use backreferences as such::
"<Match: '354aa', groups=('a',)>"

To find out what card the pair consists of, one could use the
:meth:`~Match.group` method of the match object in the following manner:

.. doctest::
:meth:`~Match.group` method of the match object in the following manner::

>>> pair = re.compile(r".*(.).*\1")
>>> pair.match("717ak").group(1)
'7'

Expand Down Expand Up @@ -1377,7 +1374,9 @@ easily read and modified by Python as demonstrated in the following example that
creates a phonebook.

First, here is the input. Normally it may come from a file, here we are using
triple-quoted string syntax::
triple-quoted string syntax

.. doctest::

>>> text = """Ross McFluff: 834.345.1254 155 Elm Street
...
Expand Down
Loading

0 comments on commit 859c068

Please sign in to comment.