Skip to content

Commit

Permalink
Support for Python 3.12 sanic-org#2836
Browse files Browse the repository at this point in the history
  • Loading branch information
iAndriy committed Dec 17, 2023
1 parent d0bbcf5 commit c3fa036
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- { python-version: "3.10", tox-env: py310, max-attempts: 3 }
- { python-version: "3.10", tox-env: py310-no-ext, max-attempts: 3 }
- { python-version: "3.11", tox-env: py311, max-attempts: 3 }
- { python-version: "3.12", tox-env: py312, max-attempts: 3 }
- { python-version: "3.11", tox-env: py311-no-ext, max-attempts: 3 }
- { python-version: "3.8", tox-env: py38-no-ext, platform: windows-latest, ignore-errors: true }
- { python-version: "3.9", tox-env: py39-no-ext, platform: windows-latest, ignore-errors: true }
Expand Down
2 changes: 1 addition & 1 deletion sanic/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "23.12.0"
__version__ = "23.12.1"
4 changes: 2 additions & 2 deletions sanic/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def __getattr__(self, key: str) -> str:
if key.startswith("_"):
return self.__getattribute__(key)
key = key.rstrip("_").replace("_", "-")
return ",".join(self.getall(key, default=[]))
return ",".join(self.getall(key, []))

def get_all(self, key: str):
"""Convenience method mapped to ``getall()``."""
return self.getall(key, default=[])
return self.getall(key, [])


use_trio = sys.argv[0].endswith("hypercorn") and "trio" in sys.argv
Expand Down
9 changes: 3 additions & 6 deletions tests/test_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from websockets.frames import CTRL_OPCODES, DATA_OPCODES, Frame
from websockets.frames import CTRL_OPCODES, DATA_OPCODES, Frame, OP_TEXT

from sanic.exceptions import ServerError
from sanic.server.websockets.frame import WebsocketFrameAssembler
Expand Down Expand Up @@ -210,17 +210,14 @@ async def test_ws_frame_put_message_complete(opcode):
@pytest.mark.asyncio
@pytest.mark.parametrize("opcode", DATA_OPCODES)
async def test_ws_frame_put_message_into_queue(opcode):
foo = 'foo' if (opcode == OP_TEXT) else b"foo"
assembler = WebsocketFrameAssembler(Mock())
assembler.chunks_queue = AsyncMock(spec=Queue)
assembler.message_fetched = AsyncMock()
assembler.message_fetched.is_set = Mock(return_value=False)

await assembler.put(Frame(opcode, b"foo"))

assembler.chunks_queue.put.has_calls(
call(b"foo"),
call(None),
)
assert assembler.chunks_queue.put.call_args_list == [call(foo), call(None)]


@pytest.mark.asyncio
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[tox]
envlist = py38, py39, py310, py311, pyNightly, pypy310, {py38,py39,py310,py311,pyNightly,pypy310}-no-ext, lint, check, security, docs, type-checking
envlist = py38, py39, py310, py311, py312, pyNightly, pypy310, {py38,py39,py310,py311,py312,pyNightly,pypy310}-no-ext, lint, check, security, docs, type-checking

[testenv]
usedevelop = true
setenv =
{py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UJSON=1
{py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
{py38,py39,py310,py311,py312,pyNightly}-no-ext: SANIC_NO_UJSON=1
{py38,py39,py310,py311,py312,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
extras = test, http3
deps =
httpx>=0.23
setuptools
allowlist_externals =
pytest
coverage
Expand Down

0 comments on commit c3fa036

Please sign in to comment.