-
Notifications
You must be signed in to change notification settings - Fork 227
Open
Description
I'm trying to reproduce but couldn't. But the new executor works with old sync.py (https://github.com/django/asgiref/blob/3.8.1/asgiref/sync.py)
The test code structure is like:
import pytest
from django.test.client import AsyncClient
from django.utils import timezone
from polls.models import Question
pytestmark = pytest.mark.django_db
@pytest.fixture
async def question():
return await Question.objects.acreate(
question_text="Sample Question", pub_date=timezone.now()
)
@pytest.fixture
async def api_response(question, async_client: AsyncClient):
response = await async_client.get("/api/questions/")
assert response.status_code == 200
return response.json()
async def test_index1(question, api_response, async_client: AsyncClient):
response = await async_client.delete(
"/polls/", headers={"X-Test-Data": "".join(api_response["questions"])}
)
assert response.status_code == 200 # could not reach here
assert response.content == b"Hello, world. You're at the polls index."
async def test_index2(question, api_response, async_client: AsyncClient):
response = await async_client.get(
"/polls/", headers={"X-Test-Data": "".join(api_response["questions"])}
)
assert response.status_code == 200
assert response.content == b"Hello, world. You're at the polls index."
pyproject.toml
[project]
description = "Add your description here"
name = "asgiref-debug"
readme = "README.md"
requires-python = ">=3.13"
version = "0.1.0"
dependencies = [
"asgiref>=3.9.1",
"django>=5.2.4",
"django-ninja>=1.4.3",
]
[dependency-groups]
dev = [
"pytest>=8.4.1",
"pytest-asyncio>=1.1.0",
"pytest-django>=4.11.1",
"ruff>=0.12.4",
]
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "mysite.settings"
asyncio_default_fixture_loop_scope = "session"
asyncio_mode = "auto"
Metadata
Metadata
Assignees
Labels
No labels