forked from pool/python-falcon
Compare commits
13 Commits
Author | SHA256 | Date | |
---|---|---|---|
15db1c7b10 | |||
a2b3838aaf | |||
a6380da2fc | |||
0d376a7d0e | |||
eb5851ecc2 | |||
828e29922b | |||
322d819fee | |||
03cdd46458 | |||
823c2f6e8e | |||
ec693d0a80 | |||
47f9b5d457 | |||
5edd96e9d9 | |||
c74f12e20f |
BIN
falcon-3.1.3.tar.gz
(Stored with Git LFS)
BIN
falcon-3.1.3.tar.gz
(Stored with Git LFS)
Binary file not shown.
BIN
falcon-4.0.2.tar.gz
(Stored with Git LFS)
Normal file
BIN
falcon-4.0.2.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -1,13 +0,0 @@
|
||||
Index: falcon-3.1.3/docs/conf.py
|
||||
===================================================================
|
||||
--- falcon-3.1.3.orig/docs/conf.py
|
||||
+++ falcon-3.1.3/docs/conf.py
|
||||
@@ -132,7 +132,7 @@ exclude_patterns = ['_build', '_newsfrag
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
-pygments_style = 'github'
|
||||
+pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
@@ -1,3 +1,87 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 19 12:18:37 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Convert to libalternatives on SLE-16-based and newer systems
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 8 13:19:46 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Convert to libalternatives
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 25 15:51:05 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Add websockets.patch to fix test failure
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 9 11:57:38 UTC 2025 - Daniel Garcia <daniel.garcia@suse.com>
|
||||
|
||||
- Build doc package just for tumbleweed to remove
|
||||
pydata-sphinx-theme requirement
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 12 10:49:26 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
|
||||
|
||||
- Update to 4.0.2
|
||||
* Running Mypy on code that uses parts of falcon.testing would
|
||||
previously lead to errors like:
|
||||
"Name "falcon.testing.TestClient" is not defined"
|
||||
This has been fixed by explicitly exporting the names that
|
||||
are imported into the falcon.testing namespace. (#2387)
|
||||
* The printable PDF version of our documentation was enabled
|
||||
on Read the Docs. (#2365)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Nov 2 06:33:44 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- Update to 4.0.1:
|
||||
* Overview
|
||||
+ CPython 3.11 - 3.13 is now fully supported.
|
||||
+ End-of-life Python 3.5, 3.6 & 3.7 are no longer supported.
|
||||
+ End-of-life Python 3.8 is no longer actively supported.
|
||||
+ Type checking support was introduced.
|
||||
+ Falcon is no longer vendoring the python-mimeparse library.
|
||||
+ A number of undocumented internal helpers were renamed to start with an
|
||||
underscore.
|
||||
+ A number of previously deprecated methods, attributes and classes have
|
||||
now been removed.
|
||||
+ We decided, on the other hand, to keep the deprecated falcon.API alias
|
||||
until Falcon 5.0.
|
||||
+ The deprecated api_helpers was removed in favor of the app_helpers
|
||||
module.
|
||||
+ The function falcon.http_date_to_dt now validates HTTP dates to have
|
||||
the correct timezone set. It now also returns timezone-aware
|
||||
datetime.datetime objects.
|
||||
+ setup.cfg was dropped in favor of consolidating all static project
|
||||
configuration in pyproject.toml
|
||||
* New & Improved
|
||||
+ A new path converter falcon.routing.PathConverter
|
||||
capable of matching segments that include / was added.
|
||||
+ Similar to the existing falcon.routing.IntConverter, a new
|
||||
falcon.routing.FloatConverter has been added, allowing to convert
|
||||
path segments to float.
|
||||
+ A new method falcon.Request.get_header_as_int was implemented.
|
||||
+ A new property, falcon.Request.headers_lower, was added to provide a
|
||||
unified, self-documenting way to get a copy of all request headers with
|
||||
lowercase names to facilitate case-insensitive matching.
|
||||
+ In Python 3.13, the cgi module is removed entirely from the stdlib,
|
||||
including its parse_header() method. Falcon addresses the issue by
|
||||
shipping an own implementation.
|
||||
+ The falcon.CORSMiddleware now properly handles the missing Allow
|
||||
header case, by denying the preflight CORS request.
|
||||
+ Added falcon.testing.Result.content_type and
|
||||
falcon.testing.StreamedResult.content_type as a utility accessor
|
||||
for the Content-Type header.
|
||||
+ A new flag, falcon.ResponseOptions.xml_error_serialization, has been
|
||||
added to falcon.ResponseOptions that can be used to disable automatic
|
||||
XML serialization of falcon.HTTPError when using the default error
|
||||
serializer (and the client prefers it).
|
||||
* Fixed
|
||||
+ The web servers used for tests are now run through sys.executable.
|
||||
* Dropped patches, no longer required:
|
||||
- python-falcon-sphinx-pygments-style.patch
|
||||
- support-new-uvicorn.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Apr 2 01:45:24 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-falcon
|
||||
#
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -16,29 +16,53 @@
|
||||
#
|
||||
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%bcond_without doc
|
||||
%else
|
||||
%bcond_with doc
|
||||
%endif
|
||||
%if 0%{?suse_version} > 1500
|
||||
%bcond_without libalternatives
|
||||
%else
|
||||
%bcond_with libalternatives
|
||||
%endif
|
||||
%{?sle15_python_module_pythons}
|
||||
Name: python-falcon
|
||||
Version: 3.1.3
|
||||
Version: 4.0.2
|
||||
Release: 0
|
||||
Summary: A web framework for building APIs and app backends
|
||||
License: Apache-2.0
|
||||
URL: http://falconframework.org
|
||||
URL: https://falconframework.org
|
||||
Source: https://files.pythonhosted.org/packages/source/f/falcon/falcon-%{version}.tar.gz
|
||||
# github pygments style is not available
|
||||
Patch0: python-falcon-sphinx-pygments-style.patch
|
||||
# PATCH-FIX-UPSTREAM Based on gh#falconry/falcon#2216
|
||||
Patch1: support-new-uvicorn.patch
|
||||
# PATCH-FIX-UPSTREAM https://github.com/falconry/falcon/pull/2406 chore(tests/asgi): migrate to the new websockets async client
|
||||
Patch0: websockets.patch
|
||||
BuildRequires: %{python_module PyYAML}
|
||||
BuildRequires: %{python_module Sphinx}
|
||||
BuildRequires: %{python_module base >= 3.8}
|
||||
BuildRequires: %{python_module ddt}
|
||||
BuildRequires: %{python_module httpx}
|
||||
BuildRequires: %{python_module myst-parser >= 2}
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module sphinx-design}
|
||||
BuildRequires: %{python_module sphinx-tabs}
|
||||
BuildRequires: %{python_module sphinxcontrib-copybutton}
|
||||
BuildRequires: %{python_module websockets}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
%if %{with libalternatives}
|
||||
BuildRequires: alts
|
||||
Requires: alts
|
||||
%else
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun): update-alternatives
|
||||
%endif
|
||||
Suggests: %{name}-doc
|
||||
BuildArch: noarch
|
||||
# TODO: Cython support
|
||||
#BuildRequires: %%{python_module Cython}
|
||||
#Requires: python-Cython
|
||||
# SECTION test requirements
|
||||
BuildRequires: %{python_module aiofiles}
|
||||
BuildRequires: %{python_module cbor2}
|
||||
@@ -50,16 +74,12 @@ BuildRequires: %{python_module testtools}
|
||||
%if 0%{?suse_version} >= 1550
|
||||
BuildRequires: %{python_module httpx if (%python-base without python36-base)}
|
||||
BuildRequires: %{python_module uvicorn if (%python-base without python36-base)}
|
||||
BuildRequires: %{python_module websockets if (%python-base without python36-base)}
|
||||
BuildRequires: %{python_module websockets >= 13.1 if (%python-base without python36-base)}
|
||||
%endif
|
||||
%if %{with doc}
|
||||
BuildRequires: %{python_module pydata-sphinx-theme}
|
||||
%endif
|
||||
# /SECTION
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
#Requires: python-Cython
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun): update-alternatives
|
||||
Suggests: %{name}-doc
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
%package -n %{name}-doc
|
||||
@@ -85,28 +105,38 @@ rm tests/test_media_handlers.py
|
||||
%build
|
||||
export CFLAGS="%{optflags} -fno-strict-aliasing"
|
||||
%pyproject_wheel
|
||||
|
||||
%if %{with doc}
|
||||
export PYTHONPATH="$(pwd)"
|
||||
pushd docs
|
||||
make html
|
||||
rm _build/html/.buildinfo
|
||||
popd
|
||||
%endif
|
||||
|
||||
%install
|
||||
%pyproject_install
|
||||
%python_clone -a %{buildroot}%{_bindir}/falcon-bench
|
||||
%python_clone -a %{buildroot}%{_bindir}/falcon-inspect-app
|
||||
%python_clone -a %{buildroot}%{_bindir}/falcon-print-routes
|
||||
%python_group_libalternatives falcon-bench falcon-inspect-app falcon-print-routes
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%if %{with doc}
|
||||
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}-doc
|
||||
cp -ar docs/_build/html examples %{buildroot}%{_defaultdocdir}/%{name}-doc/
|
||||
%fdupes %{buildroot}%{_defaultdocdir}/%{name}-doc/
|
||||
%endif
|
||||
|
||||
%check
|
||||
export LANG=en_US.UTF8
|
||||
%pytest tests
|
||||
%pytest
|
||||
|
||||
%pre
|
||||
%python_libalternatives_reset_alternative falcon-bench
|
||||
|
||||
%post
|
||||
%{python_install_alternative falcon-bench falcon-inspect-app falcon-print-routes}
|
||||
%python_install_alternative falcon-bench falcon-inspect-app falcon-print-routes
|
||||
|
||||
%postun
|
||||
%python_uninstall_alternative falcon-bench
|
||||
@@ -120,7 +150,9 @@ export LANG=en_US.UTF8
|
||||
%{python_sitelib}/falcon
|
||||
%{python_sitelib}/falcon-%{version}.dist-info
|
||||
|
||||
%if %{with doc}
|
||||
%files -n %{name}-doc
|
||||
%doc %{_defaultdocdir}/%{name}-doc
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
|
@@ -1,192 +0,0 @@
|
||||
From 13da50949751de6683b57221c2ab5f1fdce8eb50 Mon Sep 17 00:00:00 2001
|
||||
From: Vytautas Liuolia <vytautas.liuolia@gmail.com>
|
||||
Date: Wed, 13 Mar 2024 16:31:00 +0100
|
||||
Subject: [PATCH 1/7] chore(asyncio): replace `get_event_loop()` ->
|
||||
`get_running_loop()` where applicable
|
||||
|
||||
---
|
||||
tests/asgi/test_scope.py | 6 +++---
|
||||
tests/dump_asgi.py | 2 +-
|
||||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
Index: falcon-3.1.3/tests/asgi/test_scope.py
|
||||
===================================================================
|
||||
--- falcon-3.1.3.orig/tests/asgi/test_scope.py
|
||||
+++ falcon-3.1.3/tests/asgi/test_scope.py
|
||||
@@ -70,7 +70,7 @@ def test_supported_asgi_version(version,
|
||||
resp_event_collector = testing.ASGIResponseEventCollector()
|
||||
|
||||
async def task():
|
||||
- coro = asyncio.get_event_loop().create_task(
|
||||
+ coro = asyncio.get_running_loop().create_task(
|
||||
app(scope, req_event_emitter, resp_event_collector)
|
||||
)
|
||||
|
||||
@@ -142,7 +142,7 @@ def test_lifespan_scope_default_version(
|
||||
scope = {'type': 'lifespan'}
|
||||
|
||||
async def t():
|
||||
- t = asyncio.get_event_loop().create_task(
|
||||
+ t = asyncio.get_running_loop().create_task(
|
||||
app(scope, req_event_emitter, resp_event_collector)
|
||||
)
|
||||
|
||||
@@ -196,7 +196,7 @@ def test_lifespan_scope_version(spec_ver
|
||||
return
|
||||
|
||||
async def t():
|
||||
- t = asyncio.get_event_loop().create_task(
|
||||
+ t = asyncio.get_running_loop().create_task(
|
||||
app(scope, req_event_emitter, resp_event_collector)
|
||||
)
|
||||
|
||||
Index: falcon-3.1.3/tests/dump_asgi.py
|
||||
===================================================================
|
||||
--- falcon-3.1.3.orig/tests/dump_asgi.py
|
||||
+++ falcon-3.1.3/tests/dump_asgi.py
|
||||
@@ -23,5 +23,5 @@ async def app(scope, receive, send):
|
||||
}
|
||||
)
|
||||
|
||||
- loop = asyncio.get_event_loop()
|
||||
+ loop = asyncio.get_running_loop()
|
||||
loop.create_task(_say_hi())
|
||||
Index: falcon-3.1.3/falcon/util/sync.py
|
||||
===================================================================
|
||||
--- falcon-3.1.3.orig/falcon/util/sync.py
|
||||
+++ falcon-3.1.3/falcon/util/sync.py
|
||||
@@ -4,7 +4,9 @@ from functools import partial
|
||||
from functools import wraps
|
||||
import inspect
|
||||
import os
|
||||
+from typing import Awaitable
|
||||
from typing import Callable
|
||||
+from typing import TypeVar
|
||||
|
||||
|
||||
__all__ = [
|
||||
@@ -18,6 +20,42 @@ __all__ = [
|
||||
]
|
||||
|
||||
|
||||
+Result = TypeVar('Result')
|
||||
+
|
||||
+
|
||||
+class _DummyRunner:
|
||||
+ def run(self, coro: Awaitable[Result]) -> Result: # pragma: nocover
|
||||
+ # NOTE(vytas): Work around get_event_loop deprecation in 3.10 by going
|
||||
+ # via get_event_loop_policy(). This should be equivalent for
|
||||
+ # async_to_sync's use case as it is currently impossible to invoke
|
||||
+ # run_until_complete() from a running loop anyway.
|
||||
+ return self.get_loop().run_until_complete(coro)
|
||||
+
|
||||
+ def get_loop(self) -> asyncio.AbstractEventLoop: # pragma: nocover
|
||||
+ return asyncio.get_event_loop_policy().get_event_loop()
|
||||
+
|
||||
+ def close(self) -> None: # pragma: nocover
|
||||
+ pass
|
||||
+
|
||||
+
|
||||
+class _ActiveRunner:
|
||||
+ def __init__(self, runner_cls: type):
|
||||
+ self._runner_cls = runner_cls
|
||||
+ self._runner = runner_cls()
|
||||
+
|
||||
+ # TODO(vytas): This typing is wrong on py311+, but mypy accepts it.
|
||||
+ # It doesn't, OTOH, accept any of my ostensibly valid attempts to
|
||||
+ # describe it.
|
||||
+ def __call__(self) -> _DummyRunner:
|
||||
+ # NOTE(vytas): Sometimes our runner's loop can get picked and consumed
|
||||
+ # by other utilities and test methods. If that happens, recreate the runner.
|
||||
+ if self._runner.get_loop().is_closed():
|
||||
+ # NOTE(vytas): This condition is never hit on _DummyRunner.
|
||||
+ self._runner = self._runner_cls() # pragma: nocover
|
||||
+ return self._runner
|
||||
+
|
||||
+
|
||||
+_active_runner = _ActiveRunner(getattr(asyncio, 'Runner', _DummyRunner))
|
||||
_one_thread_to_rule_them_all = ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
|
||||
@@ -207,8 +245,13 @@ def async_to_sync(coroutine, *args, **kw
|
||||
one will be created.
|
||||
|
||||
Warning:
|
||||
- This method is very inefficient and is intended primarily for testing
|
||||
- and prototyping.
|
||||
+ Executing async code in this manner is inefficient since it involves
|
||||
+ synchronization via threading primitives, and is intended primarily for
|
||||
+ testing, prototyping or compatibility purposes.
|
||||
+
|
||||
+ Note:
|
||||
+ On Python 3.11+, this function leverages a module-wide
|
||||
+ ``asyncio.Runner``.
|
||||
|
||||
Args:
|
||||
coroutine: A coroutine function to invoke.
|
||||
@@ -217,17 +260,7 @@ def async_to_sync(coroutine, *args, **kw
|
||||
Keyword Args:
|
||||
**kwargs: Additional args are passed through to the coroutine function.
|
||||
"""
|
||||
-
|
||||
- # TODO(vytas): The canonical way of doing this for simple use cases is
|
||||
- # asyncio.run(), but that would be a breaking change wrt the above
|
||||
- # documented behaviour; breaking enough to break some of our own tests.
|
||||
-
|
||||
- # NOTE(vytas): Work around get_event_loop deprecation in 3.10 by going via
|
||||
- # get_event_loop_policy(). This should be equivalent for async_to_sync's
|
||||
- # use case as it is currently impossible to invoke run_until_complete()
|
||||
- # from a running loop anyway.
|
||||
- loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
- return loop.run_until_complete(coroutine(*args, **kwargs))
|
||||
+ return _active_runner().run(coroutine(*args, **kwargs))
|
||||
|
||||
|
||||
def runs_sync(coroutine):
|
||||
Index: falcon-3.1.3/pyproject.toml
|
||||
===================================================================
|
||||
--- falcon-3.1.3.orig/pyproject.toml
|
||||
+++ falcon-3.1.3/pyproject.toml
|
||||
@@ -63,7 +63,6 @@ filterwarnings = [
|
||||
"ignore:.cgi. is deprecated and slated for removal:DeprecationWarning",
|
||||
"ignore:path is deprecated\\. Use files\\(\\) instead:DeprecationWarning",
|
||||
"ignore:This process \\(.+\\) is multi-threaded",
|
||||
- "ignore:There is no current event loop",
|
||||
]
|
||||
testpaths = [
|
||||
"tests"
|
||||
Index: falcon-3.1.3/tests/asgi/test_asgi_servers.py
|
||||
===================================================================
|
||||
--- falcon-3.1.3.orig/tests/asgi/test_asgi_servers.py
|
||||
+++ falcon-3.1.3/tests/asgi/test_asgi_servers.py
|
||||
@@ -4,6 +4,7 @@ import hashlib
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
+import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@@ -27,7 +28,9 @@ _WIN32 = sys.platform.startswith('win')
|
||||
_SERVER_HOST = '127.0.0.1'
|
||||
_SIZE_1_KB = 1024
|
||||
_SIZE_1_MB = _SIZE_1_KB**2
|
||||
-
|
||||
+# NOTE(vytas): Windows specific: {Application Exit by CTRL+C}.
|
||||
+# The application terminated as a result of a CTRL+C.
|
||||
+_STATUS_CONTROL_C_EXIT = 0xC000013A
|
||||
|
||||
_REQUEST_TIMEOUT = 10
|
||||
|
||||
@@ -610,7 +613,10 @@ def server_base_url(request):
|
||||
|
||||
yield base_url
|
||||
|
||||
- assert server.returncode == 0
|
||||
+ # NOTE(vytas): Starting with 0.29.0, Uvicorn will propagate signal
|
||||
+ # values into the return code (which is a good practice in Unix);
|
||||
+ # see also https://github.com/encode/uvicorn/pull/1600
|
||||
+ assert server.returncode in (0, -signal.SIGTERM, _STATUS_CONTROL_C_EXIT)
|
||||
|
||||
break
|
||||
|
216
websockets.patch
Normal file
216
websockets.patch
Normal file
@@ -0,0 +1,216 @@
|
||||
From cf51816a2f7cd7a23d3e1129fe9418a5fc85d8be Mon Sep 17 00:00:00 2001
|
||||
From: Vytautas Liuolia <vytautas.liuolia@gmail.com>
|
||||
Date: Mon, 11 Nov 2024 08:43:02 +0100
|
||||
Subject: [PATCH] chore(tests/asgi): migrate to the new `websockets` async
|
||||
client (#2406)
|
||||
|
||||
* chore(tests/asgi): migrate to the new `websockets` async client
|
||||
|
||||
* chore: update the unsupported WS protocol exception for Daphne/Hypercorn
|
||||
---
|
||||
requirements/tests | 2 +-
|
||||
tests/asgi/test_asgi_servers.py | 67 +++++++++++++++++----------------
|
||||
2 files changed, 35 insertions(+), 34 deletions(-)
|
||||
|
||||
diff --git a/requirements/tests b/requirements/tests
|
||||
index ada7c3729..36825fd23 100644
|
||||
--- a/requirements/tests
|
||||
+++ b/requirements/tests
|
||||
@@ -13,7 +13,7 @@ testtools; python_version < '3.10'
|
||||
aiofiles
|
||||
httpx
|
||||
uvicorn >= 0.17.0
|
||||
-websockets
|
||||
+websockets >= 13.1
|
||||
|
||||
# Handler Specific
|
||||
cbor2
|
||||
diff --git a/tests/asgi/test_asgi_servers.py b/tests/asgi/test_asgi_servers.py
|
||||
index eb35ac62d..044d46a38 100644
|
||||
--- a/tests/asgi/test_asgi_servers.py
|
||||
+++ b/tests/asgi/test_asgi_servers.py
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
try:
|
||||
import websockets
|
||||
+ import websockets.asyncio.client
|
||||
import websockets.exceptions
|
||||
except ImportError:
|
||||
websockets = None # type: ignore
|
||||
@@ -232,9 +233,9 @@ async def test_hello(
|
||||
if close_code:
|
||||
extra_headers['X-Close-Code'] = str(close_code)
|
||||
|
||||
- async with websockets.connect(
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
server_url_events_ws,
|
||||
- extra_headers=extra_headers,
|
||||
+ additional_headers=extra_headers,
|
||||
) as ws:
|
||||
got_message = False
|
||||
|
||||
@@ -273,22 +274,22 @@ async def test_rejected(self, explicit_close, close_code, server_url_events_ws):
|
||||
if close_code:
|
||||
extra_headers['X-Close-Code'] = str(close_code)
|
||||
|
||||
- with pytest.raises(websockets.exceptions.InvalidStatusCode) as exc_info:
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ with pytest.raises(websockets.exceptions.InvalidStatus) as exc_info:
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
):
|
||||
pass
|
||||
|
||||
- assert exc_info.value.status_code == 403
|
||||
+ assert exc_info.value.response.status_code == 403
|
||||
|
||||
async def test_missing_responder(self, server_url_events_ws):
|
||||
server_url_events_ws += '/404'
|
||||
|
||||
- with pytest.raises(websockets.exceptions.InvalidStatusCode) as exc_info:
|
||||
- async with websockets.connect(server_url_events_ws):
|
||||
+ with pytest.raises(websockets.exceptions.InvalidStatus) as exc_info:
|
||||
+ async with websockets.asyncio.client.connect(server_url_events_ws):
|
||||
pass
|
||||
|
||||
- assert exc_info.value.status_code == 403
|
||||
+ assert exc_info.value.response.status_code == 403
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'subprotocol, expected',
|
||||
@@ -301,9 +302,9 @@ async def test_select_subprotocol_known(
|
||||
self, subprotocol, expected, server_url_events_ws
|
||||
):
|
||||
extra_headers = {'X-Subprotocol': subprotocol}
|
||||
- async with websockets.connect(
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
server_url_events_ws,
|
||||
- extra_headers=extra_headers,
|
||||
+ additional_headers=extra_headers,
|
||||
subprotocols=['amqp', 'wamp'],
|
||||
) as ws:
|
||||
assert ws.subprotocol == expected
|
||||
@@ -312,9 +313,9 @@ async def test_select_subprotocol_unknown(self, server_url_events_ws):
|
||||
extra_headers = {'X-Subprotocol': 'xmpp'}
|
||||
|
||||
try:
|
||||
- async with websockets.connect(
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
server_url_events_ws,
|
||||
- extra_headers=extra_headers,
|
||||
+ additional_headers=extra_headers,
|
||||
subprotocols=['amqp', 'wamp'],
|
||||
):
|
||||
pass
|
||||
@@ -329,8 +330,8 @@ async def test_select_subprotocol_unknown(self, server_url_events_ws):
|
||||
except websockets.exceptions.NegotiationError as ex:
|
||||
assert 'unsupported subprotocol: xmpp' in str(ex)
|
||||
|
||||
- # Daphne
|
||||
- except websockets.exceptions.InvalidMessage:
|
||||
+ # Daphne, Hypercorn
|
||||
+ except EOFError:
|
||||
pass
|
||||
|
||||
# NOTE(kgriffs): When executing this test under pytest with the -s
|
||||
@@ -340,8 +341,8 @@ async def test_select_subprotocol_unknown(self, server_url_events_ws):
|
||||
# but the usual ways of capturing stdout/stderr with pytest do
|
||||
# not work.
|
||||
async def test_disconnecting_client_early(self, server_url_events_ws):
|
||||
- ws = await websockets.connect(
|
||||
- server_url_events_ws, extra_headers={'X-Close': 'True'}
|
||||
+ ws = await websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers={'X-Close': 'True'}
|
||||
)
|
||||
await asyncio.sleep(0.2)
|
||||
|
||||
@@ -361,8 +362,8 @@ async def test_disconnecting_client_early(self, server_url_events_ws):
|
||||
async def test_send_before_accept(self, server_url_events_ws):
|
||||
extra_headers = {'x-accept': 'skip'}
|
||||
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
) as ws:
|
||||
message = await ws.recv()
|
||||
assert message == 'OperationNotAllowed'
|
||||
@@ -370,8 +371,8 @@ async def test_send_before_accept(self, server_url_events_ws):
|
||||
async def test_recv_before_accept(self, server_url_events_ws):
|
||||
extra_headers = {'x-accept': 'skip', 'x-command': 'recv'}
|
||||
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
) as ws:
|
||||
message = await ws.recv()
|
||||
assert message == 'OperationNotAllowed'
|
||||
@@ -379,8 +380,8 @@ async def test_recv_before_accept(self, server_url_events_ws):
|
||||
async def test_invalid_close_code(self, server_url_events_ws):
|
||||
extra_headers = {'x-close': 'True', 'x-close-code': 42}
|
||||
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
) as ws:
|
||||
start = time.time()
|
||||
|
||||
@@ -395,22 +396,22 @@ async def test_invalid_close_code(self, server_url_events_ws):
|
||||
async def test_close_code_on_unhandled_error(self, server_url_events_ws):
|
||||
extra_headers = {'x-raise-error': 'generic'}
|
||||
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
) as ws:
|
||||
await ws.wait_closed()
|
||||
|
||||
- assert ws.close_code in {3011, 1011}
|
||||
+ assert ws.protocol.close_code in {3011, 1011}
|
||||
|
||||
async def test_close_code_on_unhandled_http_error(self, server_url_events_ws):
|
||||
extra_headers = {'x-raise-error': 'http'}
|
||||
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
) as ws:
|
||||
await ws.wait_closed()
|
||||
|
||||
- assert ws.close_code == 3400
|
||||
+ assert ws.protocol.close_code == 3400
|
||||
|
||||
@pytest.mark.parametrize('mismatch', ['send', 'recv'])
|
||||
@pytest.mark.parametrize('mismatch_type', ['text', 'data'])
|
||||
@@ -420,8 +421,8 @@ async def test_type_mismatch(self, mismatch, mismatch_type, server_url_events_ws
|
||||
'X-Mismatch-Type': mismatch_type,
|
||||
}
|
||||
|
||||
- async with websockets.connect(
|
||||
- server_url_events_ws, extra_headers=extra_headers
|
||||
+ async with websockets.asyncio.client.connect(
|
||||
+ server_url_events_ws, additional_headers=extra_headers
|
||||
) as ws:
|
||||
if mismatch == 'recv':
|
||||
if mismatch_type == 'text':
|
||||
@@ -431,13 +432,13 @@ async def test_type_mismatch(self, mismatch, mismatch_type, server_url_events_ws
|
||||
|
||||
await ws.wait_closed()
|
||||
|
||||
- assert ws.close_code in {3011, 1011}
|
||||
+ assert ws.protocol.close_code in {3011, 1011}
|
||||
|
||||
async def test_passing_path_params(self, server_base_url_ws):
|
||||
expected_feed_id = '1ee7'
|
||||
url = f'{server_base_url_ws}feeds/{expected_feed_id}'
|
||||
|
||||
- async with websockets.connect(url) as ws:
|
||||
+ async with websockets.asyncio.client.connect(url) as ws:
|
||||
feed_id = await ws.recv()
|
||||
assert feed_id == expected_feed_id
|
||||
|
Reference in New Issue
Block a user