Flaky with pytest breaks Ctrl+C
Closed this issue · 2 comments
Simply the presence of flaky
plugin will prevent Ctrl+C from stopping the test suite. Flaky will register the KeyboardInterrupt
as a test failure -- as opposed to pure pytest, which will stop the test suite.
Version information is in the test log below.
with flaky
:
$ pytest
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-5.0.1, py-1.7.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/matejcik/a/.hypothesis/examples')
Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type>
rootdir: /home/matejcik/a
plugins: hypothesis-4.4.3, random-order-1.0.4, cov-2.7.1, asyncio-0.10.0, flaky-3.6.0
collected 1 item
test_pytest.py ^CF [100%]
=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________
def test_foo():
> time.sleep(10)
E KeyboardInterrupt
test_pytest.py:4: KeyboardInterrupt
=========================== 1 failed in 0.80 seconds ===========================
without flaky
:
$ pytest -p no:flaky
============================================================ test session starts ============================================================
platform linux -- Python 3.6.8, pytest-5.0.1, py-1.7.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/matejcik/a/.hypothesis/examples')
Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type>
rootdir: /home/matejcik/a
plugins: hypothesis-4.4.3, random-order-1.0.4, cov-2.7.1, asyncio-0.10.0
collected 1 item
test_pytest.py ^C
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/home/matejcik/a/test_pytest.py:4: KeyboardInterrupt
(to show a full traceback on KeyboardInterrupt use --fulltrace)
======================================================= no tests ran in 1.94 seconds ========================================================
Thanks @matejcik for the report. I think this probably started happening somewhat recently, due to a pytest refactor (for pytest versions >= 4).
pytest-dev/pytest#4299 refactored a pytest class (CallInfo
). Before, the logic was that keyboard exception would be reraised by default. Afterward, the default was to reraise nothing, and the caller needs to specify exceptions to reraise, which flaky doesn't do.
I think a fix should be fairly simple.
Fixed in #157 and released as 3.6.1
.