Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout support via pytest-timeout #136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Sep 3, 2023

  1. Add timeout support via pytest-timeout

    Whenever the trio_timeout option is enabled, this plugin will hook into
    requests from pytest-timeout to set a timeout. It will then start a
    thread in the background that, after the timeout has reached, will
    inject a system task in the test loop. This system task will collect
    stacktraces for all tasks and raise an exception that will terminate the
    test. The timeout thread is reused for other tests as well to not incur
    a startup cost for every test.
    
    Since this feature integrates with pytest-timeout, it also honors things
    like whether a debugger is attached or not.
    
    Drawbacks:
    
    - Ideally, whether trio does timeouts should not be a global option, but
      would be better suited for the timeout-method in pytest-timeout. This
      would require a change in pytest-timeout to let plugins register other
      timeout methods.
    - This method requires a functioning loop.
    
    Fixes python-trio#53
    VincentVanlaer committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    ea74f06 View commit details
    Browse the repository at this point in the history
  2. Use monkeypatch to set strict_exception_groups

    The pytest tester does not run tests in a subinterpreter or subprocess,
    so changing trio.run in a testdir test will also change the global
    trio.run. Monkeypatching resets trio.run after the test.
    VincentVanlaer committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    34ebecb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fb245f6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8ff6718 View commit details
    Browse the repository at this point in the history