This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Travis CI: doctest failure
Type: Stage: resolved
Components: Documentation Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, lukasz.langa, mdk, methane, vstinner
Priority: release blocker Keywords: patch

Created on 2019-04-11 02:49 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12775 merged vstinner, 2019-04-11 07:30
PR 12776 merged methane, 2019-04-11 08:15
PR 12778 merged methane, 2019-04-11 08:56
PR 12779 merged methane, 2019-04-11 09:30
Messages (18)
msg339919 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 02:49
On my https://github.com/python/cpython/pull/12770 the doctest job of Travis CI failed with:

https://travis-ci.org/python/cpython/jobs/518572326

mkdir -p build
Building NEWS from Misc/NEWS.d with blurb
PATH=./venv/bin:$PATH sphinx-build -b doctest -d build/doctrees -D latex_elements.papersize= -q -W -j4 -W . build/doctest 
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
/home/travis/build/python/cpython/Doc/tools/extensions/pyspecific.py:274: RemovedInSphinx30Warning: env.note_versionchange() is deprecated. Please use ChangeSetDomain.note_changeset() instead.
  env.note_versionchange('deprecated', version[0], node, self.lineno)
Warning, treated as error:
**********************************************************************
File "library/unittest.mock-examples.rst", line ?, in default
Failed example:
    m.one().two().three()
Expected:
    <MagicMock name='mock.one().two().three()' id='...'>
Got:
    obj dead or exiting
    <MagicMock name='mock.one().two().three()' id='140222049958880'>
Makefile:44: recipe for target 'build' failed
make[1]: *** [build] Error 2

--

I can reproduce this issue on Linux with:

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

I get random errors:

Warning, treated as error:
**********************************************************************
File "library/datetime.rst", line 686, in default
Failed example:
    d.strftime("%A %d. %B %Y")
Expected:
    'Monday 11. March 2002'
Got:
    'lundi 11. mars 2002'

Warning, treated as error:
**********************************************************************
File "library/collections.rst", line 914, in default
Failed example:
    p._asdict()
Expected:
    {'x': 11, 'y': 22}
Got:
    OrderedDict([('x', 11), ('y', 22)])

Warning, treated as error:
**********************************************************************
File "library/unittest.mock.rst", line ?, in default
Failed example:
    mock.call_args.args
Expected:
    (3, 4)
Got:
    args


The virtual environment uses Sphinx 2.0.1. Can it be a change in Sphinx 2 default configuration?
msg339932 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 07:25
Well, same problem with Sphinx 1.8.5. No idea why the job started to fail.
msg339933 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 07:33
On Thu, Apr 11, 2019 at 11:49 AM STINNER Victor <report@bugs.python.org> wrote:
>
> File "library/unittest.mock-examples.rst", line ?, in default
> Failed example:
>     m.one().two().three()
> Expected:
>     <MagicMock name='mock.one().two().three()' id='...'>
> Got:
>     obj dead or exiting
>     <MagicMock name='mock.one().two().three()' id='140222049958880'>

I'm not sure where "obj is dead or exiting" came from.

> File "library/datetime.rst", line 686, in default
> Failed example:
>     d.strftime("%A %d. %B %Y")
> Expected:
>     'Monday 11. March 2002'
> Got:
>     'lundi 11. mars 2002'

It seems it is caused by non English locale.

> File "library/collections.rst", line 914, in default
> Failed example:
>     p._asdict()
> Expected:
>     {'x': 11, 'y': 22}
> Got:
>     OrderedDict([('x', 11), ('y', 22)])

You may run doctest with existing Python, not Python 3.8.

> File "library/unittest.mock.rst", line ?, in default
> Failed example:
>     mock.call_args.args
> Expected:
>     (3, 4)
> Got:
>     args

I'm not sure about this.
-- 
Inada Naoki  <songofacandy@gmail.com>
msg339934 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 07:36
> It seems it is caused by non English locale.

Right, but why did it start to fail since yesterday?


> You may run doctest with existing Python, not Python 3.8.

I used the command from the .travis.yml job: "... make -C Doc/ PYTHON=../python "...". It explicitly picks the Python it just compiled.

Why would we like to check the doctests using a random Python version, whereas it's Python 3.8 documentation?
msg339935 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 07:46
8 hours ago, the job still passed at the top of the the master branch (commit a9bd8925c7fa50dd3cfab125b824ec192133ef49):

https://travis-ci.org/python/cpython/jobs/518281237

"Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Pygments-2.3.1 Sphinx-2.0.1 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 packaging-19.0 pyparsing-2.4.0 python-docs-theme-2018.7 pytz-2019.1 requests-2.21.0 six-1.12.0 snowballstemmer-1.2.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"
...
PATH=./venv/bin:$PATH sphinx-build -b doctest -d build/doctrees -D latex_elements.papersize= -q -W -j4 -W . build/doctest 
...
The command "xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W -j4" doctest" exited with 0.

---

6 hours ago, it failed:

https://travis-ci.org/python/cpython/jobs/518572326

Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Pygments-2.3.1 Sphinx-2.0.1 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 packaging-19.0 pyparsing-2.4.0 python-docs-theme-2018.7 pytz-2019.1 requests-2.21.0 six-1.12.0 snowballstemmer-1.2.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

Warning, treated as error: (...)

--

In the 2 builds, pip installed the the same Python modules versions.

I compared the raw logs of the 2 builds. In short, they are the same.

Maybe the job already failed previously, but only randomly?
msg339936 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 07:46
> > It seems it is caused by non English locale.
>
> Right, but why did it start to fail since yesterday?

Is it an error start to fail since yesterday?
As far as reading your first report, this is happen only in your local
environment.

> > You may run doctest with existing Python, not Python 3.8.
>
> I used the command from the .travis.yml job: "... make -C Doc/ PYTHON=../python "...". It explicitly picks the Python it just compiled.

This error is in your environment too.  Maybe you re-used old venv?

>
> Why would we like to check the doctests using a random Python version, whereas it's Python 3.8 documentation?
>

Because it "doctest".  Python behavior (repr) can be changed.
Python 3.8 replaces some OrderedDict usage with regular dict.
msg339937 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 07:46
New changeset adff01e81d291c698581eadd693caa43ae5c78ac by Victor Stinner in branch 'master':
bpo-36597: Disable Travis CI doctest job (GH-12775)
https://github.com/python/cpython/commit/adff01e81d291c698581eadd693caa43ae5c78ac
msg339938 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 07:47
I mark this issue as a release blocker to not forget it. I disabled the Travis CI doctest job to repair the CI, but we have to investigate why it started to fail yesterday.
msg339939 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 07:49
> As far as reading your first report, this is happen only in your local
environment.

See the beginning of my first message, the doctest prevents me to merge a PR. But I tested on the master branch without my change, and I get the same issue locally, and the issues seems to be unrelated to my change.

"""
On my https://github.com/python/cpython/pull/12770 the doctest job of Travis CI failed with:

https://travis-ci.org/python/cpython/jobs/518572326
"""
msg339940 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-04-11 07:54
"Object dead or exiting" is a less frequent random error with doctest. I am not sure from where it occurs but occurs for different tests at different times and is overlooked in Travis since the next runs are fine.

Sample old builds : 

https://travis-ci.org/python/cpython/jobs/517606752
https://travis-ci.org/python/cpython/jobs/510847596
msg339941 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 07:57
> See the beginning of my first message, the doctest prevents me to merge a PR.


You did not show travis build link which failed other than "obj dead or exiting" error.
Don't all other errors happened only on your environment?  If no, please link to travis build link.

As far as I can confirm now, only "obj dead or exiting" error is problem in Travis.


> But I tested on the master branch without my change, and I get the same issue locally, and the issues seems to be unrelated to my change.

I suspect your environment (locale and venv used to run doctest), not your changes.

> """
> On my https://github.com/python/cpython/pull/12770 the doctest job of Travis CI failed with:
> 
> https://travis-ci.org/python/cpython/jobs/518572326
> """

Only "obj dead or exiting" happened in the job.
msg339942 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 08:09
https://github.com/python/cpython/blob/master/Doc/library/weakref.rst#finalizer-objects

    >>> obj = Object()
    >>> weakref.finalize(obj, print, "obj dead or exiting")  #doctest:+ELLIPSIS
    <finalize object at ...; for 'Object' at ...>
    >>> exit()                                               #doctest:+SKIP
    obj dead or exiting

Note that "#doctest:+SKIP".  print("obj dead or exiting") is called after weakref test.
This may caused random doctest fail.
msg339943 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-11 08:19
> You did not show travis build link which failed other than "obj dead or exiting" error.

Really? When I click on https://travis-ci.org/python/cpython/jobs/518572326 (the second link of my first message), I still see:

"""
Warning, treated as error:
**********************************************************************
File "library/unittest.mock-examples.rst", line ?, in default
Failed example:
    m.one().two().three()
Expected:
    <MagicMock name='mock.one().two().three()' id='...'>
Got:
    obj dead or exiting
    <MagicMock name='mock.one().two().three()' id='140222049958880'>
Makefile:44: recipe for target 'build' failed
make[1]: *** [build] Error 2
"""

This error comes from Travis CI.

> I suspect your environment (locale and venv used to run doctest), not your changes.

You can ignore the date failure, but how is the following error related to my environment?

"""
File "library/collections.rst", line 914, in default
Failed example:
    p._asdict()
Expected:
    {'x': 11, 'y': 22}
Got:
    OrderedDict([('x', 11), ('y', 22)])
"""

I used the same commands than .travis.yml. If we are unable to get the same environment than in Travis CI, we have a big problem.

I agree to ignore the locale, this is a lower priority issue.
msg339944 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 08:23
On Thu, Apr 11, 2019 at 5:19 PM STINNER Victor <report@bugs.python.org> wrote:
> Really? When I click on https://travis-ci.org/python/cpython/jobs/518572326 (the second link of my first message), I still see:
>
> """
> Warning, treated as error:
> **********************************************************************
> File "library/unittest.mock-examples.rst", line ?, in default
> Failed example:
>     m.one().two().three()
> Expected:
>     <MagicMock name='mock.one().two().three()' id='...'>
> Got:
>     obj dead or exiting
>     <MagicMock name='mock.one().two().three()' id='140222049958880'>
> Makefile:44: recipe for target 'build' failed
> make[1]: *** [build] Error 2
> """
>
> This error comes from Travis CI.

It is "obj dead or exiting" error.  I didn't say it is caused by your
environment.
It is only error happened in Travis.

>
> > I suspect your environment (locale and venv used to run doctest), not your changes.
>
> You can ignore the date failure, but how is the following error related to my environment?
>
> """
> File "library/collections.rst", line 914, in default
> Failed example:
>     p._asdict()
> Expected:
>     {'x': 11, 'y': 22}
> Got:
>     OrderedDict([('x', 11), ('y', 22)])

namedtuple._asdict() changed to return dict instead of OrderedDict.
If your venv is created before the change, this error can be happened.
msg339945 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 08:25
I think PR-12776 fixed "obj dead or exiting" error.
https://travis-ci.org/python/cpython/jobs/518656385
msg339946 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 08:53
New changeset 57b1a2862a99677f09614e9e456d36aae9ddd87c by Inada Naoki in branch 'master':
bpo-36597: fix random doctest failure (GH-12776)
https://github.com/python/cpython/commit/57b1a2862a99677f09614e9e456d36aae9ddd87c
msg339951 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 10:05
New changeset b3c92c6ae923ffb2b9ac5f80b28ecd689de48662 by Inada Naoki in branch 'master':
bpo-36597: fix weakref example code (GH-12779)
https://github.com/python/cpython/commit/b3c92c6ae923ffb2b9ac5f80b28ecd689de48662
msg339957 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 10:37
New changeset ac31da8f3710f9f9b8dbb4c36b2108fb1e5b4a48 by Inada Naoki in branch '3.7':
bpo-36597: fix random doctest failure (GH-12778)
https://github.com/python/cpython/commit/ac31da8f3710f9f9b8dbb4c36b2108fb1e5b4a48
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80778
2019-04-11 10:38:52methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-04-11 10:37:55methanesetmessages: + msg339957
2019-04-11 10:05:39methanesetmessages: + msg339951
2019-04-11 09:30:26methanesetpull_requests: + pull_request12706
2019-04-11 08:56:29methanesetpull_requests: + pull_request12705
2019-04-11 08:53:53methanesetmessages: + msg339946
2019-04-11 08:25:16methanesetmessages: + msg339945
2019-04-11 08:23:41methanesetmessages: + msg339944
2019-04-11 08:19:16vstinnersetmessages: + msg339943
2019-04-11 08:15:40methanesetpull_requests: + pull_request12703
2019-04-11 08:09:05methanesetmessages: + msg339942
2019-04-11 07:57:50methanesetnosy: - xtreak
messages: + msg339941
2019-04-11 07:54:13xtreaksetnosy: + xtreak
messages: + msg339940
2019-04-11 07:49:11vstinnersetmessages: + msg339939
2019-04-11 07:47:47vstinnersetpriority: normal -> release blocker
nosy: + lukasz.langa
messages: + msg339938

2019-04-11 07:46:57vstinnersetmessages: + msg339937
2019-04-11 07:46:44methanesetmessages: + msg339936
2019-04-11 07:46:22vstinnersetmessages: + msg339935
2019-04-11 07:36:33vstinnersetmessages: + msg339934
2019-04-11 07:33:36methanesetnosy: + methane
messages: + msg339933
2019-04-11 07:30:00vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request12702
2019-04-11 07:25:37vstinnersetmessages: + msg339932
2019-04-11 03:02:00xtreaksetnosy: + mdk
2019-04-11 02:49:25vstinnercreate