bpo-36597: fix random doctest failure by methane · Pull Request #12776 · python/cpython

When I test your PR locally, I still get random failures. Commands:

cd Doc
make clean
make venv
LANG= PATH=./venv/bin:$PATH sphinx-build -b doctest -d build/doctrees -D latex_elements.papersize= -q -W -j4 -W . build/doctest ^C

Example of failure:

Warning, treated as error:
**********************************************************************
File "library/statistics.rst", line 126, in default
Failed example:
    fmean([3.5, 4.0, 5.25])
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.7/doctest.py", line 1329, in __run
        compileflags, 1), test.globs)
      File "<doctest default[0]>", line 1, in <module>
        fmean([3.5, 4.0, 5.25])
    NameError: name 'fmean' is not defined

My venv has these versions:

$ venv/bin/python -m pip freeze
alabaster==0.7.12
Babel==2.6.0
blurb==1.0.7
certifi==2019.3.9
chardet==3.0.4
docutils==0.14
idna==2.8
imagesize==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
packaging==19.0
Pygments==2.3.1
pyparsing==2.4.0
python-docs-theme==2018.7
pytz==2019.1
requests==2.21.0
six==1.12.0
snowballstemmer==1.2.1
Sphinx==2.0.1
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
urllib3==1.24.1