mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-03 11:11:30 +08:00
Fix pytest-asyncio configuration and treq_asgi hex escapes
- Add asyncio_mode = "auto" to pytest configuration for async tests - Update treq_asgi.py badrequest class to support hex escapes
This commit is contained in:
parent
da8bd4850a
commit
d40a374547
@ -80,6 +80,8 @@ main = "gunicorn.app.pasterapp:serve"
|
||||
norecursedirs = ["examples", "lib", "local", "src", "tests/docker"]
|
||||
testpaths = ["tests/"]
|
||||
addopts = "--assert=plain --cov=gunicorn --cov-report=xml"
|
||||
asyncio_mode = "auto"
|
||||
asyncio_default_fixture_loop_scope = "function"
|
||||
filterwarnings = [
|
||||
# Eventlet patches select module, which breaks asyncio event loop cleanup
|
||||
# This is expected behavior when testing eventlet worker
|
||||
|
||||
@ -209,13 +209,14 @@ class badrequest:
|
||||
self.fname = fname
|
||||
self.name = os.path.basename(fname)
|
||||
|
||||
with open(self.fname) as handle:
|
||||
with open(self.fname, 'rb') as handle:
|
||||
self.data = handle.read()
|
||||
self.data = self.data.replace("\n", "").replace("\\r\\n", "\r\n")
|
||||
self.data = self.data.replace("\\0", "\000").replace("\\n", "\n").replace("\\t", "\t")
|
||||
if "\\" in self.data:
|
||||
raise AssertionError("Unexpected backslash in test data")
|
||||
self.data = self.data.encode('latin1')
|
||||
self.data = self.data.replace(b"\n", b"").replace(b"\\r\\n", b"\r\n")
|
||||
self.data = self.data.replace(b"\\0", b"\000").replace(b"\\n", b"\n").replace(b"\\t", b"\t")
|
||||
# Handle hex escape sequences for binary data (e.g., \x0D for bare CR)
|
||||
self.data = decode_hex_escapes(self.data)
|
||||
if b"\\" in self.data:
|
||||
raise AssertionError("Unexpected backslash in test data - only handling HTAB, NUL, CRLF, and hex escapes")
|
||||
|
||||
def send_all(self):
|
||||
yield self.data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user