From 27361498f00b7b675c84c49702686fb4e72ead7b Mon Sep 17 00:00:00 2001 From: Liad Oz Date: Thu, 23 May 2024 09:46:02 +0300 Subject: [PATCH] fix: ensure compatability with werkzeug 3.0.0 --- .github/workflows/main.yml | 28 ++++++++++++++++++++++++++++ flask_loopback/flask_loopback.py | 5 +---- requirements.txt | 2 ++ setup.cfg | 8 ++++---- 4 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6128480 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + # manually triggered + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ".[testing]" + - name: Test with pytest + run: pytest diff --git a/flask_loopback/flask_loopback.py b/flask_loopback/flask_loopback.py index 1a82635..1501b15 100644 --- a/flask_loopback/flask_loopback.py +++ b/flask_loopback/flask_loopback.py @@ -53,7 +53,7 @@ class FlaskLoopback(object): def __init__(self, flask_app): super(FlaskLoopback, self).__init__() self.flask_app = flask_app - self._test_client = flask_app.test_client() + self._test_client = flask_app.test_client(use_cookies=False) self._request_context_handlers = [] self._registered_addresses = set() self._use_ssl = {} @@ -101,9 +101,6 @@ def handle_request(self, session, url, request): except CustomHTTPResponse as e: return e.response - self._test_client.cookie_jar.clear() - for cookie in request._cookies: # pylint: disable=protected-access - self._test_client.cookie_jar.set_cookie(cookie) resp = self._test_client.open(path, **open_kwargs) returned = requests.Response() assert returned.url is None diff --git a/requirements.txt b/requirements.txt index 1d007b5..1425340 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ requests Flask +six URLObject +werkzeug>=1.0.0 unittest2; python_version<'2.7' contextlib2; python_version<'3.3' diff --git a/setup.cfg b/setup.cfg index b400593..229f079 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,10 @@ [metadata] name = Flask-Loopback classifiers = - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3.5 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 summary = Library for faking HTTP requests using flask applications without actual network operations description-file = README.md