Skip to content

pytest should warn about threads kept alive after testing #3662

@fabioz

Description

@fabioz

Given some code such as:

def test_thread_keeps_process_alive():
    import threading
    import time

    def sleep_forever():
        while True:
            time.sleep(1000)

    threading.Thread(target=sleep_forever).start()

ideally pytest would warn that threads are still running after the test finishes (as the process is still running the ci will fail the build because of a timeout without any signal of what could be the issue).

As a note, the pydev test runner does give such a message, so, that implementation could be borrowed:

https://github.com/fabioz/PyDev.Debugger/blob/master/runfiles.py#L284

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions