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: test_inspect.py failed if module _multiprocessing not available
Type: Stage: resolved
Components: Tests Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, python-dev, rpointel
Priority: normal Keywords: patch

Created on 2013-09-30 14:15 by rpointel, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Lib_test_test_inspect_py.diff rpointel, 2013-09-30 14:15 diff to skip test_qualname_source if _multiprocessing is not importable
Messages (10)
msg198698 - (view) Author: Remi Pointel (rpointel) * Date: 2013-09-30 14:15
When I run the regress tests on OpenBSD 5.4-current, the test test_inspect.py failed because the module _multiprocessing is not available, instead of skipping the test:

FAILED (errors=1)
Traceback (most recent call last):
  File "./Lib/test/test_inspect.py", line 2453, in <module>
    test_main()
  File "./Lib/test/test_inspect.py", line 2449, in test_main
    TestBoundArguments, TestGetClosureVars, TestUnwrap, TestMain
  File "/tmp/Python-3.4.0a3/Lib/test/support/__init__.py", line 1696, in run_unittest
    _run_suite(suite)
  File "/tmp/Python-3.4.0a3/Lib/test/support/__init__.py", line 1671, in _run_suite
    raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "./Lib/test/test_inspect.py", line 2411, in test_qualname_source
    module = importlib.import_module('concurrent.futures')
  File "/tmp/Python-3.4.0a3/Lib/importlib/__init__.py", line 95, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1613, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1594, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1561, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 607, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1056, in load_module
  File "<frozen importlib._bootstrap>", line 926, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _call_with_frames_removed
  File "/tmp/Python-3.4.0a3/Lib/concurrent/futures/__init__.py", line 17, in <module>
    from concurrent.futures.process import ProcessPoolExecutor
  File "/tmp/Python-3.4.0a3/Lib/concurrent/futures/process.py", line 53, in <module>
    from multiprocessing.queues import SimpleQueue, Full
  File "/tmp/Python-3.4.0a3/Lib/multiprocessing/queues.py", line 22, in <module>
    import _multiprocessing
ImportError: No module named '_multiprocessing'


Diff to skip test_qualname_source if _multiprocessing is not available is attached. Is it ok?

Remi.
msg198704 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-09-30 14:53
test.support.import_module is typically meant for global imports as function-level imports are discouraged in general. I would instead use the unittest.skipIf decorator::

  @unittest.skipIf(not test.support.multiprocessing, "multiprocessing required") 
  def test_qualname_source(self):
    ...
msg198719 - (view) Author: Remi Pointel (rpointel) * Date: 2013-09-30 19:11
Yes, but it needs an import to use test.support.multiprocessing.
msg198720 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-09-30 19:21
New changeset d7ba4ca59023 by Brett Cannon in branch 'default':
Issue #19134: Make a test in inspect conditional on multiprocessing
http://hg.python.org/cpython/rev/d7ba4ca59023
msg198721 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-09-30 19:23
The import doesn't matter for test.support.multiprocessing as it is conditional thanks to the try/except. If that fails then the skipIf will be triggered and nothing will be executed. If the import succeeds in test.support then the importlib.import_module() call will succeed without issue. The point is that it is much more obvious why the test may get skipped from reading the code rather than looking at the function name.
msg198723 - (view) Author: Remi Pointel (rpointel) * Date: 2013-09-30 19:42
Thanks :)
msg198833 - (view) Author: Remi Pointel (rpointel) * Date: 2013-10-02 12:57
Hi,

sorry to reopen this bug but it seams that your commit was not ok:

test_qualname_source (__main__.TestMain) ... ERROR

======================================================================
ERROR: test_qualname_source (__main__.TestMain)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_inspect.py", line 2414, in test_qualname_source
    module = importlib.import_module('concurrent.futures')
  File "/home/remi/dev/cpython/Lib/importlib/__init__.py", line 95, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1613, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1594, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1561, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 607, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1056, in load_module
  File "<frozen importlib._bootstrap>", line 926, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _call_with_frames_removed
  File "/home/remi/dev/cpython/Lib/concurrent/futures/__init__.py", line 17, in <module>
    from concurrent.futures.process import ProcessPoolExecutor
  File "/home/remi/dev/cpython/Lib/concurrent/futures/process.py", line 53, in <module>
    from multiprocessing.queues import SimpleQueue, Full
  File "/home/remi/dev/cpython/Lib/multiprocessing/queues.py", line 22, in <module>
    import _multiprocessing
ImportError: No module named '_multiprocessing'

----------------------------------------------------------------------
Ran 164 tests in 1.285s

FAILED (errors=1)
Traceback (most recent call last):
  File "Lib/test/test_inspect.py", line 2456, in <module>
    test_main()
  File "Lib/test/test_inspect.py", line 2452, in test_main
    TestBoundArguments, TestGetClosureVars, TestUnwrap, TestMain
  File "/home/remi/dev/cpython/Lib/test/support/__init__.py", line 1696, in run_unittest
    _run_suite(suite)
  File "/home/remi/dev/cpython/Lib/test/support/__init__.py", line 1671, in _run_suite
    raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "Lib/test/test_inspect.py", line 2414, in test_qualname_source
    module = importlib.import_module('concurrent.futures')
  File "/home/remi/dev/cpython/Lib/importlib/__init__.py", line 95, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1613, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1594, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1561, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 607, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1056, in load_module
  File "<frozen importlib._bootstrap>", line 926, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _call_with_frames_removed
  File "/home/remi/dev/cpython/Lib/concurrent/futures/__init__.py", line 17, in <module>
    from concurrent.futures.process import ProcessPoolExecutor
  File "/home/remi/dev/cpython/Lib/concurrent/futures/process.py", line 53, in <module>
    from multiprocessing.queues import SimpleQueue, Full
  File "/home/remi/dev/cpython/Lib/multiprocessing/queues.py", line 22, in <module>
    import _multiprocessing
ImportError: No module named '_multiprocessing'

Remi.
msg198840 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-02 14:26
New changeset 2e54edaf60d4 by Brett Cannon in branch 'default':
Try to fix issue #19134 again
http://hg.python.org/cpython/rev/2e54edaf60d4
msg198841 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-10-02 14:29
OK, went for a more thorough check for the failure by just trying to import and catching the ImportError instead of trying to be fancy. The FreeBSD buildbot was having the same failure but it seems stuck waiting for some lock, so I can't verify the fix at the moment.
msg198842 - (view) Author: Remi Pointel (rpointel) * Date: 2013-10-02 14:34
It's ok now, thanks:

test_qualname_source (__main__.TestMain) ... skipped 'multiprocessing required to test __qualname__ for source files'
History
Date User Action Args
2022-04-11 14:57:51adminsetgithub: 63333
2013-10-02 14:34:41rpointelsetmessages: + msg198842
2013-10-02 14:31:23brett.cannonlinkissue19144 superseder
2013-10-02 14:29:57brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg198841

stage: resolved
2013-10-02 14:26:14python-devsetmessages: + msg198840
2013-10-02 12:57:55rpointelsetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg198833
2013-09-30 19:42:45rpointelsetmessages: + msg198723
2013-09-30 19:23:33brett.cannonsetstatus: open -> closed
assignee: brett.cannon
resolution: fixed
messages: + msg198721
2013-09-30 19:21:20python-devsetnosy: + python-dev
messages: + msg198720
2013-09-30 19:11:16rpointelsetmessages: + msg198719
2013-09-30 14:53:01brett.cannonsetnosy: + brett.cannon
messages: + msg198704
2013-09-30 14:15:42rpointelcreate