Open cielavenir opened 4 years ago
import pytest def test_a(): pass def test_b(): pytest.exit('system state unrecoverable, destroy pytest session.')
socketserver https://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py
expected: pytest -d --tx socket=localhost:8888 test_exit.py --rsyncdir=. should not freeze
pytest -d --tx socket=localhost:8888 test_exit.py --rsyncdir=.
observed: it freezes until Ctrl+C is input.
--tx ssh=localhost
log
root@0fa7f92c43b4:~# pytest -d --tx socket=localhost:8888 test_exit.py --rsyncdir=. # socketserver ==================================================================================== test session starts ===================================================================================== platform linux2 -- Python 2.7.13, pytest-4.6.9, py-1.8.1, pluggy-0.13.1 rootdir: /root plugins: xdist-1.31.0, forked-1.1.3 gw0 [2] .[gw0] node down: keyboard-interrupt f replacing crashed worker gw0 ^C ### pytest freezes until I input Ctrl+C ========================================================================================== FAILURES ========================================================================================== _____________________________________________________________________________________ root/test_exit.py ______________________________________________________________________________________ [gw0] linux2 -- Python 2.7.13 /usr/bin/python worker 'gw0' crashed while running 'root/test_exit.py::test_b' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /usr/local/lib/python2.7/dist-packages/execnet/gateway_socket.py:28: KeyboardInterrupt (to show a full traceback on KeyboardInterrupt use --fulltrace) ============================================================================= 1 failed, 1 passed in 2.58 seconds ============================================================================= root@0fa7f92c43b4:~# pytest -d --tx ssh=localhost test_exit.py --rsyncdir=. # ssh ==================================================================================== test session starts ===================================================================================== platform linux2 -- Python 2.7.13, pytest-4.6.9, py-1.8.1, pluggy-0.13.1 rootdir: /root plugins: xdist-1.31.0, forked-1.1.3 gw0 [2] .[gw0] node down: keyboard-interrupt f replacing crashed worker gw0 gw1 C ========================================================================================== FAILURES ========================================================================================== _____________________________________________________________________________________ root/test_exit.py ______________________________________________________________________________________ [gw0] linux2 -- Python 2.7.13 /usr/bin/python worker 'gw0' crashed while running 'root/test_exit.py::test_b' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: <WorkerController gw0> received keyboard-interrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ============================================================================= 1 failed, 1 passed in 1.08 seconds =============================================================================
It seems that using pytest.exit(returncode=1) works for our purpose.
pytest.exit(returncode=1)
socketserver https://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py
expected:
pytest -d --tx socket=localhost:8888 test_exit.py --rsyncdir=.
should not freezeobserved: it freezes until Ctrl+C is input.
--tx ssh=localhost
is fine.log