Note that there are some explanatory texts on larger screens.

plurals
  1. POpy.test: how to automatically detect an exception in a child process?
    primarykey
    data
    text
    <p>I'm running py.test on Linux in the context of a module that makes heavy usage of multiprocessing. Exceptions in child processes are not detected as an error. Example test file <code>pytest_mp_test.py</code>:</p> <pre><code>import multiprocessing def test_mp(): p = multiprocessing.Process(target=child) p.start() p.join() def child(): assert False </code></pre> <p>Execution:</p> <pre><code>$ py.test pytest_mp_test.py ================================== test session starts =================================== platform linux2 -- Python 2.7.3 -- pytest-2.3.3 plugins: cov collected 1 items pytest_mp_test.py . ================================ 1 passed in 0.04 seconds ================================ </code></pre> <p>No error detected. The exception is printed when invoked with <code>-s</code>:</p> <pre><code>$ py.test -s pytest_mp_test.py ================================== test session starts =================================== platform linux2 -- Python 2.7.3 -- pytest-2.3.3 plugins: cov collected 1 items pytest_mp_test.py Process Process-1: Traceback (most recent call last): File "/apps11/bioinfp/Python-2.7.3/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap self.run() File "/apps11/bioinfp/Python-2.7.3/lib/python2.7/multiprocessing/process.py", line 114, in run self._target(*self._args, **self._kwargs) File "/home/bioinfp/jang/hobbyproggorn/gevent-messagepipe/gevent-messagepipe/pytest_mp_test.py", line 9, in child assert False AssertionError: assert False . ================================ 1 passed in 0.04 seconds ================================ </code></pre> <p>When I manually review the test log, I realize when there is a problem. However, <strong>I am wondering if there a neat way to automate exception detection in a child with py.test.</strong></p> <p>Must I verify the child's exit code in the parent? Is this the only way?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload