pytest-dev / pytest-timeout

MIT License
216 stars 64 forks source link

Disable timeout on debugging #32

Closed pytest-timeout-bot closed 4 years ago

pytest-timeout-bot commented 5 years ago

Original report by Anonymous.


Hi,

I am looking for an option to disable pytest-timeout when executing in debug mode, even tests under @pytest.mark.timeout(...). Any option I could pass?

Thanks for help in advance.

pytest-timeout-bot commented 5 years ago

Original comment by Pascal Chambon (Bitbucket: pchambon, GitHub: pchambon).


Haha I’ve been kicked out of debugging sessions by pytest-timeout too, that being said I have no idea how it might detect that the program is being debugged, in a portable way.

pytest-timeout-bot commented 5 years ago

Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).


pytest-timeout already implements the pytest_exception_interact and the pytest_enter_pdb hooks which solved most people’s problems around debugging, e.g. it will work nicely with pytest --pdb. What else do you need provided? If you’re just after an option on the command line you could just use --timeout=999999 and probably be fine.

graingert commented 4 years ago

this could probably be fixed py patching sys.breakpointhook

graingert commented 4 years ago

And asking users to use @asottile's breakpoint backport

Mattwmaster58 commented 4 years ago

@graingert Could you point out where to find that patch?

This could probably be fixed py patching sys.breakpointhook

Are there any plans to add this functionality? One could also use this answer on SO, although it requires the user to have a breakpoint set at the very beginning of the session.

Mattwmaster58 commented 4 years ago

It looks like pytest actual attempts this with, but it's obviously not enough:

@pytest.hookimpl
def pytest_enter_pdb():
    # Since pdb.set_trace happens outside of any pytest control, we don't have
    # any pytest ``item`` here, so we cannot use timeout_teardown. Thus, we
    # need another way to signify that the timeout should not be performed.
    global SUPPRESS_TIMEOUT
    SUPPRESS_TIMEOUT = True