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 async fixture in testing docs #8457

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Conversation

Dreamsorcerer
Copy link
Member

Instead of low-level asyncio APIs, which regular users shouldn't be using.

@Dreamsorcerer Dreamsorcerer added the bot:chronographer:skip This PR does not need to include a change note label Jun 12, 2024
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.64%. Comparing base (444ed95) to head (c619b74).
Report is 412 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8457   +/-   ##
=======================================
  Coverage   97.64%   97.64%           
=======================================
  Files         107      107           
  Lines       33067    33067           
  Branches     3885     3885           
=======================================
  Hits        32288    32288           
  Misses        562      562           
  Partials      217      217           
Flag Coverage Δ
CI-GHA 97.55% <ø> (ø)
OS-Linux 97.22% <ø> (ø)
OS-Windows 95.64% <ø> (ø)
OS-macOS 96.88% <ø> (ø)
Py-3.10.11 97.03% <ø> (-0.01%) ⬇️
Py-3.10.14 96.98% <ø> (ø)
Py-3.11.9 97.20% <ø> (ø)
Py-3.12.3 97.33% <ø> (ø)
Py-3.8.10 95.41% <ø> (ø)
Py-3.8.18 96.87% <ø> (ø)
Py-3.9.13 97.01% <ø> (ø)
Py-3.9.19 96.97% <ø> (ø)
Py-pypy7.3.16 96.54% <ø> (ø)
VM-macos 96.88% <ø> (ø)
VM-ubuntu 97.22% <ø> (ø)
VM-windows 95.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@webknjaz
Copy link
Member

I think that injecting the loop fixture is still good for isolation. Even in our tests, we sometimes get one test influencing the other when the loop leaks.

P.S. I didn't know you could make async fixtures. Are they new?
P.P.S. I'll be going to the pytest development sprint next week and maybe will learn more new stuff as well..

@Dreamsorcerer
Copy link
Member Author

I think that injecting the loop fixture is still good for isolation. Even in our tests, we sometimes get one test influencing the other when the loop leaks.

aiohttp_client depends on the loop fixture, so that's not something for the user to be concerned with.

P.S. I didn't know you could make async fixtures. Are they new?

We've been using them in various places for atleast a couple of years. So, probably supported since 2-5 years ago.

@webknjaz
Copy link
Member

I think that injecting the loop fixture is still good for isolation. Even in our tests, we sometimes get one test influencing the other when the loop leaks.

aiohttp_client depends on the loop fixture, so that's not something for the user to be concerned with.

I wonder why our tests get hit by this, then..

Anyway, I don't have anything against the patch in general. Just wanted to clarify this bit.

@webknjaz
Copy link
Member

I think that injecting the loop fixture is still good for isolation. Even in our tests, we sometimes get one test influencing the other when the loop leaks.

aiohttp_client depends on the loop fixture, so that's not something for the user to be concerned with.

P.S. I didn't know you could make async fixtures. Are they new?

We've been using them in various places for atleast a couple of years. So, probably supported since 2-5 years ago.

Could you check what's the oldest pytest where this works? Perhaps it'd be nice to document if this doesn't work on something ancient.

@Dreamsorcerer
Copy link
Member Author

Could you check what's the oldest pytest where this works? Perhaps it'd be nice to document if this doesn't work on something ancient.

I think it's actually supported by pytest-asyncio (same as tests). Maybe our original code before using pytest-asyncio didn't support fixtures. It's not clear to me when exactly it became available (or if it even wasn't), but it seems unlikely people will encounter a problem.

@Dreamsorcerer Dreamsorcerer merged commit db1b912 into master Jun 13, 2024
40 of 41 checks passed
@Dreamsorcerer Dreamsorcerer deleted the Dreamsorcerer-patch-4 branch June 13, 2024 18:11
Copy link
Contributor

patchback bot commented Jun 13, 2024

Backport to 3.9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.9/db1b9129e5f9e3c3730d81a2ae8de059c3e38732/pr-8457

Backported as #8460

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jun 13, 2024
Copy link
Contributor

patchback bot commented Jun 13, 2024

Backport to 3.10: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.10/db1b9129e5f9e3c3730d81a2ae8de059c3e38732/pr-8457

Backported as #8461

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jun 13, 2024
Dreamsorcerer added a commit that referenced this pull request Jun 13, 2024
…8461)

**This is a backport of PR #8457 as merged into master
(db1b912).**

Co-authored-by: Sam Bull <git@sambull.org>
Dreamsorcerer added a commit that referenced this pull request Jun 13, 2024
…8460)

**This is a backport of PR #8457 as merged into master
(db1b912).**

Co-authored-by: Sam Bull <git@sambull.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:skip This PR does not need to include a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants