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

Use latest dependencies for Testbed testing #2652

Merged
merged 4 commits into from
Jun 15, 2024

Conversation

rmartin16
Copy link
Member

@rmartin16 rmartin16 commented Jun 14, 2024

Changes

  • Recent versions of pytest-asyncio introduced a lot of breaking changes. Notably, a session-wide event loop can no longer be specified via the event_loop() fixture. However, an event loop policy can be specified via the event_loop_policy() fixture.
  • As such, this introduces a simple event loop policy that defers to the existing event loop proxy
  • Closes Testbed works in run, but hangs in test #2382
  • Also, allows Dependabot to manage the testbed's dependencies

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@rmartin16
Copy link
Member Author

rmartin16 commented Jun 14, 2024

So, these changes in pytest-asyncio have not been particularly well accepted by the community....but it seems the maintainer was between a rock and hard spot in trying to manage upstream deprecations in asyncio itself...although, there's also evidence of potentially less-than-ideal design choices.

At any rate, once I was able to wrap my head around how any of this even works, there is where I landed. Fortunately, Toga's use of pytest-asyncio here is relatively straightforward relative to other use-cases from which I was seeking inspiration.

A potentially notable aspect of this approach stems from the fact that pytest-asyncio defaults to isolating all tests to their own event loop; there are several strategies for expanding the scope of an event loop. My strategy here, though, allows pytest-asyncio to "create" a new event loop for each test....but, via this new policy, the same event loop is returned for each "new loop request".

My asyncio skills are what they are....so definitely open to better approaches.

Finally, in trying to understand the linux failures in CI (i.e #2648), I figured it was a good idea to get on the latest versions of everything first.

- Recent versions of pytest-asyncio introduced a lot of breaking
  changes. Notably, a session-wide event loop can no longer be specified
  via the ``event_loop()`` fixture. However, an event loop policy can be
  specified via the ``event_loop_policy()`` fixture.
- As such, this introduces a simple event loop policy that defers to the
  existing event loop proxy.
@rmartin16 rmartin16 marked this pull request as ready for review June 14, 2024 22:09
@freakboy3742
Copy link
Member

My asyncio skills are what they are....so definitely open to better approaches.

... My good sir, you are massively underselling your skill set here :-)

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me golf claps.

Nice work - both on the nice hack to get dependabot updating the testbed dependencies, and to get pytest-asyncio up to date.

One minor suggestion to limit the scope of a dependency; but otherwise this looks great.

testbed/pyproject.toml Show resolved Hide resolved
testbed/pyproject.toml Outdated Show resolved Hide resolved
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@freakboy3742 freakboy3742 merged commit 4c56839 into beeware:main Jun 15, 2024
31 of 34 checks passed
@rmartin16 rmartin16 deleted the pytest-asyncio-bump branch June 15, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testbed works in run, but hangs in test
2 participants