<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>pytest on Amin Alaee</title>
    <link>https://aminalaee.github.io/tags/pytest/</link>
    <description>Recent content in pytest on Amin Alaee</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Thu, 29 Jun 2023 12:00:06 +0100</lastBuildDate><atom:link href="https://aminalaee.github.io/tags/pytest/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Pytest async tests and fixtures</title>
      <link>https://aminalaee.github.io/posts/2023/pytest-async-tests/</link>
      <pubDate>Thu, 29 Jun 2023 12:00:06 +0100</pubDate>
      
      <guid>https://aminalaee.github.io/posts/2023/pytest-async-tests/</guid>
      <description>Async tests and fixtures Pytest already has the official pytest-asyncio plugin which allows you to write async tests and fixtures.
According to pytest-asyncio docs, you can have an async test with an async fixture like this:
from typing import Any, AsyncGenerator import pytest import pytest_asyncio from httpx import AsyncClient @pytest_asyncio.fixture async def client() -&amp;gt; AsyncGenerator[AsyncClient, Any]: async with AsyncClient() as c: yield c @pytest.mark.asyncio async def test_api_call(client: AsyncClient) -&amp;gt; None: response = await client.</description>
    </item>
    
  </channel>
</rss>
