mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-26 18:35:05 +00:00
docs: distinguish Flask and FastAPI testing fixtures
(cherry picked from commit 2353740d9e)
This commit is contained in:
1 parent
5367671a22
commit
5aa13c7d33
2 files changed
+20
-12
No files matched your search
@@ -224,7 +224,7 @@ def test_without_fixture_call():
|
||||
assert Config.get_setting("debug") is False
|
||||
```
|
||||
|
||||
### Conftest.py for Shared Fixtures
|
||||
### Conftest.py for Shared Fixtures (Flask)
|
||||
|
||||
```python
|
||||
# tests/conftest.py
|
||||
@@ -484,14 +484,18 @@ async def test_async_with_fixture(async_client):
|
||||
assert response.status_code == 200
|
||||
```
|
||||
|
||||
### Async Fixture
|
||||
### Async Fixture (FastAPI)
|
||||
|
||||
```python
|
||||
@pytest.fixture
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def async_client():
|
||||
"""Async fixture providing async test client."""
|
||||
app = create_app()
|
||||
async with app.test_client() as client:
|
||||
app = create_app() # Returns a FastAPI application
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
yield client
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -661,7 +665,7 @@ class TestUserService:
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### Testing API Endpoints (FastAPI/Flask)
|
||||
### Testing API Endpoints (Flask)
|
||||
|
||||
```python
|
||||
@pytest.fixture
|
||||
|
||||
Reference in new issue
Block a user