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

Add reusable client tests and refactor #74

Merged
merged 1 commit into from
May 3, 2024

Conversation

hamedsh
Copy link
Contributor

@hamedsh hamedsh commented Jan 7, 2024

In Python 3.12, its required to close the writer to stop the server. unless its hangs on wait_closed

how to reproduce:
python=3.12.x

import pytest
from sanic import Sanic, response

from sanic_testing.reusable import ReusableClient


@pytest.fixture
def reusable_app():
    sanic_app = Sanic(__name__)

    @sanic_app.get("/")
    def basic(request):
        return response.text("foo")

    return sanic_app


@pytest.mark.asyncio
def test_basic_asgi_client(reusable_app):
    client = ReusableClient(reusable_app)
    with client:
        request, response = client.get("/")

        assert request.method.lower() == "get"
        assert response.body == b"foo"
        assert response.status == 200

in python 3.12, its required to close the writer to stop the server. unless its hangs on `wait_closed`
@dnikolayev
Copy link

Hey @ahopkins

Sorry for asking: when could we expect the merging of this PR / releasing a new version of sanic-testing?

Thanks a lot!

@ahopkins ahopkins merged commit c60e403 into sanic-org:main May 3, 2024
5 checks passed
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.

3 participants