Skip to content

Commit

Permalink
Merge pull request #862 from kevin1024/test-on-313
Browse files Browse the repository at this point in the history
Start testing with CPython 3.13
  • Loading branch information
hartwork authored Sep 18, 2024
2 parents 71eb624 + f5597fa commit 1ca708d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "pypy-3.8"
- "pypy-3.9"
- "pypy-3.10"
Expand Down Expand Up @@ -48,6 +49,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: pip
allow-prereleases: true

- name: Install project dependencies
run: |
Expand Down
16 changes: 0 additions & 16 deletions tests/integration/conftest.py

This file was deleted.

22 changes: 13 additions & 9 deletions tests/integration/test_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
import ssl
import urllib.parse

import pytest
import pytest_httpbin.certs

import vcr

Expand All @@ -11,6 +13,8 @@

from .aiohttp_utils import aiohttp_app, aiohttp_request # noqa: E402

HTTPBIN_SSL_CONTEXT = ssl.create_default_context(cafile=pytest_httpbin.certs.where())


def run_in_loop(fn):
async def wrapper():
Expand Down Expand Up @@ -338,7 +342,7 @@ def test_double_requests(tmpdir, httpbin):
assert cassette.play_count == 2


def test_cookies(httpbin_both, httpbin_ssl_context, tmpdir):
def test_cookies(httpbin_both, tmpdir):
async def run(loop):
cookies_url = httpbin_both.url + (
"/response-headers?"
Expand All @@ -353,25 +357,25 @@ async def run(loop):
# ------------------------- Record -------------------------- #
with vcr.use_cassette(tmp) as cassette:
async with aiohttp.ClientSession(loop=loop, cookie_jar=aiohttp.CookieJar(unsafe=True)) as session:
cookies_resp = await session.get(cookies_url, ssl=httpbin_ssl_context)
cookies_resp = await session.get(cookies_url, ssl=HTTPBIN_SSL_CONTEXT)
home_resp = await session.get(
home_url,
cookies=req_cookies,
headers=req_headers,
ssl=httpbin_ssl_context,
ssl=HTTPBIN_SSL_CONTEXT,
)
assert cassette.play_count == 0
assert_responses(cookies_resp, home_resp)

# -------------------------- Play --------------------------- #
with vcr.use_cassette(tmp, record_mode=vcr.mode.NONE) as cassette:
async with aiohttp.ClientSession(loop=loop, cookie_jar=aiohttp.CookieJar(unsafe=True)) as session:
cookies_resp = await session.get(cookies_url, ssl=httpbin_ssl_context)
cookies_resp = await session.get(cookies_url, ssl=HTTPBIN_SSL_CONTEXT)
home_resp = await session.get(
home_url,
cookies=req_cookies,
headers=req_headers,
ssl=httpbin_ssl_context,
ssl=HTTPBIN_SSL_CONTEXT,
)
assert cassette.play_count == 2
assert_responses(cookies_resp, home_resp)
Expand All @@ -388,7 +392,7 @@ def assert_responses(cookies_resp, home_resp):
run_in_loop(run)


def test_cookies_redirect(httpbin_both, httpbin_ssl_context, tmpdir):
def test_cookies_redirect(httpbin_both, tmpdir):
async def run(loop):
# Sets cookie as provided by the query string and redirects
cookies_url = httpbin_both.url + "/cookies/set?Cookie_1=Val_1"
Expand All @@ -397,7 +401,7 @@ async def run(loop):
# ------------------------- Record -------------------------- #
with vcr.use_cassette(tmp) as cassette:
async with aiohttp.ClientSession(loop=loop, cookie_jar=aiohttp.CookieJar(unsafe=True)) as session:
cookies_resp = await session.get(cookies_url, ssl=httpbin_ssl_context)
cookies_resp = await session.get(cookies_url, ssl=HTTPBIN_SSL_CONTEXT)
assert not cookies_resp.cookies
cookies = session.cookie_jar.filter_cookies(cookies_url)
assert cookies["Cookie_1"].value == "Val_1"
Expand All @@ -408,7 +412,7 @@ async def run(loop):
# -------------------------- Play --------------------------- #
with vcr.use_cassette(tmp, record_mode=vcr.mode.NONE) as cassette:
async with aiohttp.ClientSession(loop=loop, cookie_jar=aiohttp.CookieJar(unsafe=True)) as session:
cookies_resp = await session.get(cookies_url, ssl=httpbin_ssl_context)
cookies_resp = await session.get(cookies_url, ssl=HTTPBIN_SSL_CONTEXT)
assert not cookies_resp.cookies
cookies = session.cookie_jar.filter_cookies(cookies_url)
assert cookies["Cookie_1"].value == "Val_1"
Expand All @@ -422,7 +426,7 @@ async def run(loop):
"Cookie_1=Val_1; Expires=Wed, 21 Oct 2015 07:28:00 GMT",
]
async with aiohttp.ClientSession(loop=loop, cookie_jar=aiohttp.CookieJar(unsafe=True)) as session:
cookies_resp = await session.get(cookies_url, ssl=httpbin_ssl_context)
cookies_resp = await session.get(cookies_url, ssl=HTTPBIN_SSL_CONTEXT)
assert not cookies_resp.cookies
cookies = session.cookie_jar.filter_cookies(cookies_url)
assert cookies["Cookie_1"].value == "Val_1"
Expand Down

0 comments on commit 1ca708d

Please sign in to comment.