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

Adding __aenter__ and __aexit__ Methods to AsyncHTMLSession #556

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added async context manager test
Curtidor committed Aug 15, 2023
commit 6f46110cd0b7e453e6b270db5106f755ba3fef78
11 changes: 11 additions & 0 deletions tests/test_requests_html.py
Original file line number Diff line number Diff line change
@@ -326,6 +326,17 @@ async def test_async_browser_session():

@pytest.mark.asyncio
async def test_async_context_manager():
"""
Test the behavior of the async context manager for AsyncHTMLSession.

This test case validates that the AsyncHTMLSession instance can be used
as an asynchronous context manager, and the session can successfully make
an HTTP GET request within the context.

Note: If the user has no connection, a ConnectionError may occur, and the
test will be skipped.

"""
async with AsyncHTMLSession() as s:
try:
results = await s.get('https://www.google.com')