diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 70f574d..d11e149 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 64f965e..30b1644 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ pretty: black --line-length 79 sanic_testing tests isort --line-length 79 sanic_testing tests +install: + python -m venv venv + venv/bin/pip install --editable .[dev] +test: + venv/bin/pytest tests diff --git a/requirements.testing.txt b/requirements.testing.txt index 8728dbe..9cf68d8 100644 --- a/requirements.testing.txt +++ b/requirements.testing.txt @@ -1,3 +1,4 @@ git+https://github.com/sanic-org/sanic.git pytest pytest-asyncio +setuptools diff --git a/sanic_testing/__init__.py b/sanic_testing/__init__.py index 4b4f2af..7c35c4d 100644 --- a/sanic_testing/__init__.py +++ b/sanic_testing/__init__.py @@ -1,4 +1,4 @@ from sanic_testing.manager import TestManager -__version__ = "23.6.0" +__version__ = "23.6.1" __all__ = ("TestManager",) diff --git a/sanic_testing/reusable.py b/sanic_testing/reusable.py index b3d2efd..9bd928c 100644 --- a/sanic_testing/reusable.py +++ b/sanic_testing/reusable.py @@ -112,9 +112,7 @@ def _sanic_endpoint_test( if gather_request: _collect_request = partial(self._collect_request, request_data) - self.app.request_middleware.appendleft( # type: ignore - _collect_request - ) + self.app.request_middleware.appendleft(_collect_request) # type: ignore # noqa for route in self.app.router.routes: if _collect_request not in route.extra.request_middleware: @@ -137,9 +135,7 @@ def _sanic_endpoint_test( ) try: - self.app.request_middleware.remove( # type: ignore - _collect_request - ) + self.app.request_middleware.remove(_collect_request) # type: ignore # noqa except BaseException: # noqa pass diff --git a/sanic_testing/testing.py b/sanic_testing/testing.py index 7bedf22..c78d40e 100644 --- a/sanic_testing/testing.py +++ b/sanic_testing/testing.py @@ -179,9 +179,7 @@ def _sanic_endpoint_test( self.app.signal_router.reset() if gather_request: - self.app.request_middleware.appendleft( # type: ignore - _collect_request - ) + self.app.request_middleware.appendleft(_collect_request) # type: ignore # noqa try: self.app.exception(MethodNotSupported)(self._error_handler) @@ -246,9 +244,7 @@ def _sanic_endpoint_test( if gather_request: try: - self.app.request_middleware.remove( # type: ignore - _collect_request - ) + self.app.request_middleware.remove(_collect_request) # type: ignore # noqa except BaseException: # noqa pass @@ -388,8 +384,8 @@ async def request( # type: ignore url = f"{scheme}://{ASGI_HOST}:{ASGI_PORT}{url}" if self._collect_request not in self.sanic_app.request_middleware: - self.sanic_app.request_middleware.appendleft( # type: ignore - self._collect_request + self.sanic_app.request_middleware.appendleft( + self._collect_request # type: ignore ) self.gather_request = gather_request diff --git a/setup.py b/setup.py index cec092c..977daa9 100644 --- a/setup.py +++ b/setup.py @@ -45,12 +45,19 @@ def open_local(paths, mode="r", encoding="utf8"): "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], } requirements = ["httpx>=0.18"] -tests_require = ["pytest", "sanic>=22.12", "pytest-asyncio"] +tests_require = [ + "pytest", "sanic>=22.12", "pytest-asyncio", + "setuptools;python_version>'3.11'" +] setup_kwargs["install_requires"] = requirements setup_kwargs["tests_require"] = tests_require +setup_kwargs["extras_require"] = { + 'dev': tests_require +} setup(**setup_kwargs) diff --git a/tox.ini b/tox.ini index 1e04349..ddc3dee 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38, py39, py310, py311, check +envlist = py38, py39, py310, py311, py312, check [gh-actions] python = @@ -7,6 +7,7 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] deps =