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 support for Python 3.13 #350

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
version:
["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- version: "2.7"
container: python:2.7.18-buster
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Multimedia :: Graphics
Expand All @@ -47,6 +48,7 @@ test =
pytest
pytest-cov
requests_mock
multipart; python_version >= '3.13'

lint =
autoflake==2.3.1; python_version >= '3.8'
Expand Down
29 changes: 23 additions & 6 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import json
import gazu.client
import io
import cgi


def fakeid(string):
Expand Down Expand Up @@ -38,12 +37,30 @@ def add_verify_file_callback(mock, dict_assert={}, url=None):
def verify_file_callback(request):
if url is None or url == request.url:
body_file = io.BytesIO(request.body)
_, pdict = cgi.parse_header(request.headers["Content-Type"])
if sys.version_info[0] == 3:
pdict["boundary"] = bytes(pdict["boundary"], "UTF-8")

if sys.version_info >= (3, 13):
import multipart

p = multipart.MultipartParser(
body_file,
boundary=bytes(
multipart.parse_options_header(
request.headers["Content-Type"]
)[1]["boundary"],
"UTF-8",
),
charset="UTF-8",
)
parsed = {part.name: [part.raw] for part in p.parts()}
else:
pdict["boundary"] = bytes(pdict["boundary"])
parsed = cgi.parse_multipart(fp=body_file, pdict=pdict)
import cgi

_, pdict = cgi.parse_header(request.headers["Content-Type"])
if sys.version_info[0] == 3:
pdict["boundary"] = bytes(pdict["boundary"], "utf-8")
else:
pdict["boundary"] = bytes(pdict["boundary"])
parsed = cgi.parse_multipart(fp=body_file, pdict=pdict)
for key in dict_assert.keys():
assert key in parsed.keys()
if isinstance(parsed[key][0], bytes):
Expand Down