Skip to content

Flaky with pytest breaks Ctrl+C #156

@matejcik

Description

@matejcik

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 ========================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions