Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test runner hangs during collection with doctest-modules and mock.call in module #2188

Closed
jaraco opened this issue Jan 12, 2017 · 10 comments
Closed
Labels
plugin: doctests related to the doctests builtin plugin type: bug problem that needs to be addressed

Comments

@jaraco
Copy link
Contributor

jaraco commented Jan 12, 2017

Consider this test:

$ mkdir mock_call
$ cd mock_call 
$ cat > test_this.py
from unittest.mock import call

$ python -m rwt pytest -- -m pytest --doctest-modules --collect-only
Collecting pytest
  Using cached pytest-3.0.5-py2.py3-none-any.whl
Collecting py>=1.4.29 (from pytest)
  Using cached py-1.4.32-py2.py3-none-any.whl
Installing collected packages: py, pytest
Successfully installed py-1.4.32 pytest-3.0.5
====================================== test session starts =======================================
platform darwin -- Python 3.6.0, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /Users/jaraco/mock_call, inifile: 
collecting 0 items^C
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
to show a full traceback on KeyboardInterrupt use --fulltrace
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/mock.py:2069: KeyboardInterrupt
================================== no tests ran in 5.85 seconds ==================================
$ 

The test will hang for a long time and eventually exit. It seems the doctest logic is attempting to test the call function and causes trouble during collection.

@RonnyPfannschmidt
Copy link
Member

this is a cpython bug ^^

@nicoddemus
Copy link
Member

Could you provide more information @RonnyPfannschmidt?

@RonnyPfannschmidt
Copy link
Member

@nicoddemus mock object are a easily the cause of endless recursions and errors, py.test had to add special support to avoid stumbling over those magical objects, i am certain the stdlib didn't brother to get things right

@nicoddemus
Copy link
Member

I see thanks, but is that conclusion is a general feeling or did you investigate the report by @jaraco and reached that conclusion?

@RonnyPfannschmidt
Copy link
Member

@nicoddemus we hit similar issues with some prior bugs related to py.tests own collection

@nicoddemus
Copy link
Member

I see thanks @RonnyPfannschmidt

Hmm mock.call is not a mock object, but does some getattr magic... it warrants more investigation.

@nicoddemus nicoddemus added type: bug problem that needs to be addressed plugin: doctests related to the doctests builtin plugin labels Jan 13, 2017
@jaraco
Copy link
Contributor Author

jaraco commented Jan 13, 2017

I don't know why I didn't think to try this before - when running python -m doctest test_this.py, it also hangs. That excludes pytest as a factor and points pretty squarely at CPython.

@jaraco
Copy link
Contributor Author

jaraco commented Jan 13, 2017

Which has been reported here.

@jaraco
Copy link
Contributor Author

jaraco commented Jan 13, 2017

Ugh, and I reported this previously in #1217. I thought it seemed familiar, and I did search for it.

@jaraco jaraco closed this as completed Jan 13, 2017
@nicoddemus
Copy link
Member

Thanks @jaraco!

@RonnyPfannschmidt was right after all! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: doctests related to the doctests builtin plugin type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants