Skip to content

Commit 859c068

Browse files
matrixiseJulienPalard
authored andcommitted
bpo-34962: make doctest in Doc/ now passes, and is enforced in CI (GH-9806)
1 parent 53ebf4b commit 859c068

File tree

9 files changed

+218
-73
lines changed

9 files changed

+218
-73
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ matrix:
5353
- cd Doc
5454
# Sphinx is pinned so that new versions that introduce new warnings won't suddenly cause build failures.
5555
# (Updating the version is fine as long as no warnings are raised by doing so.)
56-
# The theme used by the docs is stored seperately, so we need to install that as well.
57-
- python -m pip install sphinx~=1.6.1 blurb python-docs-theme
56+
# The theme used by the docs is stored separately, so we need to install that as well.
57+
- python -m pip install sphinx blurb python-docs-theme
5858
script:
5959
- make check suspicious html SPHINXOPTS="-q -W -j4"
6060
- os: osx
@@ -155,8 +155,14 @@ script:
155155
# Check that all symbols exported by libpython start with "Py" or "_Py"
156156
- make smelly
157157
# `-r -w` implicitly provided through `make buildbottest`.
158-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then XVFB_RUN=xvfb-run; fi; $XVFB_RUN make buildbottest TESTOPTS="-j4 -uall,-cpu"
159-
158+
- |
159+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
160+
XVFB_RUN=xvfb-run;
161+
fi
162+
$XVFB_RUN make buildbottest TESTOPTS="-j4 -uall,-cpu"
163+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
164+
$XVFB_RUN make PYTHON=../python SPHINXOPTS="-q -W -j4" -C Doc/ venv doctest
165+
fi
160166
notifications:
161167
email: false
162168
webhooks:

Doc/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
1717
'pyspecific', 'c_annotations', 'escape4chm']
1818

19+
20+
doctest_global_setup = '''
21+
try:
22+
import _tkinter
23+
except ImportError:
24+
_tkinter = None
25+
'''
1926
# General substitutions.
2027
project = 'Python'
2128
copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y')

Doc/distutils/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _examples:
1+
.. _distutils_examples:
22

33
********
44
Examples

Doc/library/multiprocessing.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,18 +621,19 @@ The :mod:`multiprocessing` package mostly replicates the API of the
621621
Example usage of some of the methods of :class:`Process`:
622622

623623
.. doctest::
624+
:options: +ELLIPSIS
624625

625626
>>> import multiprocessing, time, signal
626627
>>> p = multiprocessing.Process(target=time.sleep, args=(1000,))
627628
>>> print(p, p.is_alive())
628-
<Process(Process-1, initial)> False
629+
<Process(..., initial)> False
629630
>>> p.start()
630631
>>> print(p, p.is_alive())
631-
<Process(Process-1, started)> True
632+
<Process(..., started)> True
632633
>>> p.terminate()
633634
>>> time.sleep(0.1)
634635
>>> print(p, p.is_alive())
635-
<Process(Process-1, stopped[SIGTERM])> False
636+
<Process(..., stopped[SIGTERM])> False
636637
>>> p.exitcode == -signal.SIGTERM
637638
True
638639

Doc/library/re.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,7 @@ Checking for a Pair
12341234
^^^^^^^^^^^^^^^^^^^
12351235

12361236
In this example, we'll use the following helper function to display match
1237-
objects a little more gracefully:
1238-
1239-
.. testcode::
1237+
objects a little more gracefully::
12401238

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

12711269
To find out what card the pair consists of, one could use the
1272-
:meth:`~Match.group` method of the match object in the following manner:
1273-
1274-
.. doctest::
1270+
:meth:`~Match.group` method of the match object in the following manner::
12751271

1272+
>>> pair = re.compile(r".*(.).*\1")
12761273
>>> pair.match("717ak").group(1)
12771274
'7'
12781275

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

13791376
First, here is the input. Normally it may come from a file, here we are using
1380-
triple-quoted string syntax::
1377+
triple-quoted string syntax
1378+
1379+
.. doctest::
13811380

13821381
>>> text = """Ross McFluff: 834.345.1254 155 Elm Street
13831382
...

0 commit comments

Comments
 (0)