mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
Doctest cleanups (GH-95436)
* GHA: Don't hide doctest output * Enable doctests in math.rst * Squash warnings in nntplib.rst doctests * Squash warning in turtle.rst doctest * Squash warnings in whatsnew/3.2.rst doctests * Treat warnings as errors in Doc/ doctests
This commit is contained in:
parent
9ec6abf6dc
commit
82814624bf
6 changed files with 29 additions and 7 deletions
2
.github/workflows/doc.yml
vendored
2
.github/workflows/doc.yml
vendored
|
@ -78,4 +78,4 @@ jobs:
|
||||||
run: make -C Doc/ PYTHON=../python venv
|
run: make -C Doc/ PYTHON=../python venv
|
||||||
# Use "xvfb-run" since some doctest tests open GUI windows
|
# Use "xvfb-run" since some doctest tests open GUI windows
|
||||||
- name: 'Run documentation doctest'
|
- name: 'Run documentation doctest'
|
||||||
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" doctest
|
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="-W --keep-going" doctest
|
||||||
|
|
|
@ -22,6 +22,11 @@ try:
|
||||||
import _tkinter
|
import _tkinter
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_tkinter = None
|
_tkinter = None
|
||||||
|
# Treat warnings as errors, done here to prevent warnings in Sphinx code from
|
||||||
|
# causing spurious test failures.
|
||||||
|
import warnings
|
||||||
|
warnings.simplefilter('error')
|
||||||
|
del warnings
|
||||||
'''
|
'''
|
||||||
|
|
||||||
manpages_url = 'https://manpages.debian.org/{path}'
|
manpages_url = 'https://manpages.debian.org/{path}'
|
||||||
|
|
|
@ -108,7 +108,7 @@ Number-theoretic and representation functions
|
||||||
.. function:: fsum(iterable)
|
.. function:: fsum(iterable)
|
||||||
|
|
||||||
Return an accurate floating point sum of values in the iterable. Avoids
|
Return an accurate floating point sum of values in the iterable. Avoids
|
||||||
loss of precision by tracking multiple intermediate partial sums::
|
loss of precision by tracking multiple intermediate partial sums:
|
||||||
|
|
||||||
>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
|
>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
|
||||||
0.9999999999999999
|
0.9999999999999999
|
||||||
|
@ -371,7 +371,7 @@ Power and logarithmic functions
|
||||||
logarithms. For small floats *x*, the subtraction in ``exp(x) - 1``
|
logarithms. For small floats *x*, the subtraction in ``exp(x) - 1``
|
||||||
can result in a `significant loss of precision
|
can result in a `significant loss of precision
|
||||||
<https://en.wikipedia.org/wiki/Loss_of_significance>`_\; the :func:`expm1`
|
<https://en.wikipedia.org/wiki/Loss_of_significance>`_\; the :func:`expm1`
|
||||||
function provides a way to compute this quantity to full precision::
|
function provides a way to compute this quantity to full precision:
|
||||||
|
|
||||||
>>> from math import exp, expm1
|
>>> from math import exp, expm1
|
||||||
>>> exp(1e-5) - 1 # gives result accurate to 11 places
|
>>> exp(1e-5) - 1 # gives result accurate to 11 places
|
||||||
|
@ -654,7 +654,7 @@ Constants
|
||||||
not considered to equal to any other numeric value, including themselves. To check
|
not considered to equal to any other numeric value, including themselves. To check
|
||||||
whether a number is a NaN, use the :func:`isnan` function to test
|
whether a number is a NaN, use the :func:`isnan` function to test
|
||||||
for NaNs instead of ``is`` or ``==``.
|
for NaNs instead of ``is`` or ``==``.
|
||||||
Example::
|
Example:
|
||||||
|
|
||||||
>>> import math
|
>>> import math
|
||||||
>>> math.nan == math.nan
|
>>> math.nan == math.nan
|
||||||
|
|
|
@ -14,6 +14,23 @@
|
||||||
.. deprecated:: 3.11
|
.. deprecated:: 3.11
|
||||||
The :mod:`nntplib` module is deprecated (see :pep:`594` for details).
|
The :mod:`nntplib` module is deprecated (see :pep:`594` for details).
|
||||||
|
|
||||||
|
.. testsetup::
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter('ignore', category=DeprecationWarning)
|
||||||
|
import nntplib
|
||||||
|
|
||||||
|
.. testcleanup::
|
||||||
|
|
||||||
|
try:
|
||||||
|
s.quit()
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
import sys
|
||||||
|
# Force a warning if any other file imports nntplib
|
||||||
|
sys.modules.pop('nntplib')
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
This module defines the class :class:`NNTP` which implements the client side of
|
This module defines the class :class:`NNTP` which implements the client side of
|
||||||
|
|
|
@ -1279,7 +1279,7 @@ Appearance
|
||||||
(direction of movement).
|
(direction of movement).
|
||||||
|
|
||||||
.. doctest::
|
.. doctest::
|
||||||
:skipif: _tkinter is None
|
:skipif: _tkinter is None or 'always; deprecated method'
|
||||||
|
|
||||||
>>> turtle.reset()
|
>>> turtle.reset()
|
||||||
>>> turtle.shape("circle")
|
>>> turtle.shape("circle")
|
||||||
|
|
|
@ -322,7 +322,7 @@ aspects that are visible to the programmer:
|
||||||
* The tag that is unique to each interpreter is accessible from the :mod:`imp`
|
* The tag that is unique to each interpreter is accessible from the :mod:`imp`
|
||||||
module:
|
module:
|
||||||
|
|
||||||
>>> import imp
|
>>> import imp # doctest: +SKIP
|
||||||
>>> imp.get_tag() # doctest: +SKIP
|
>>> imp.get_tag() # doctest: +SKIP
|
||||||
'cpython-32'
|
'cpython-32'
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ aspects that are visible to the programmer:
|
||||||
be smarter. It is no longer sufficient to simply strip the "c" from a ".pyc"
|
be smarter. It is no longer sufficient to simply strip the "c" from a ".pyc"
|
||||||
filename. Instead, use the new functions in the :mod:`imp` module:
|
filename. Instead, use the new functions in the :mod:`imp` module:
|
||||||
|
|
||||||
>>> imp.source_from_cache('c:/py32/lib/__pycache__/collections.cpython-32.pyc')
|
>>> imp.source_from_cache('c:/py32/lib/__pycache__/collections.cpython-32.pyc') # doctest: +SKIP
|
||||||
'c:/py32/lib/collections.py'
|
'c:/py32/lib/collections.py'
|
||||||
>>> imp.cache_from_source('c:/py32/lib/collections.py') # doctest: +SKIP
|
>>> imp.cache_from_source('c:/py32/lib/collections.py') # doctest: +SKIP
|
||||||
'c:/py32/lib/__pycache__/collections.cpython-32.pyc'
|
'c:/py32/lib/__pycache__/collections.cpython-32.pyc'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue