Skip to content

Commit

Permalink
Merge pull request #350 from EvanBldy/main
Browse files Browse the repository at this point in the history
Add support for Python 3.13
  • Loading branch information
EvanBldy authored Nov 25, 2024
2 parents a75df53 + 6b0d897 commit 475e7ad
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
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

0 comments on commit 475e7ad

Please sign in to comment.