Skip to content

Incompatibility with werkzeug>=3.1 #197

Open
@stancld

Description

@stancld

Describe the bug
Hey, pytest flask fixtures are currently incompatible with the newer werkzeug releases.

self = <FlaskClient <Flask 'click_api.app'>>
args = (<Flask 'click_api.app'>, <class 'pytest_flask.plugin.<class 'pytest_flask.plugin.JSONResponse'>'>)
kwargs = {'use_cookies': True}
    def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
        super().__init__(*args, **kwargs)
        self.preserve_context = False
        self._new_contexts: t.List[t.ContextManager[t.Any]] = []
        self._context_stack = ExitStack()
        self.environ_base = {
            "REMOTE_ADDR": "127.0.0.1",
>           "HTTP_USER_AGENT": f"werkzeug/{werkzeug.__version__}",
        }
E       AttributeError: module 'werkzeug' has no attribute '__version__'
__class__  = <class 'flask.testing.FlaskClient'>
args       = (<Flask 'click_api.app'>,
 <class 'pytest_flask.plugin.<class 'pytest_flask.plugin.JSONResponse'>'>)
kwargs     = {'use_cookies': True}
self       = <FlaskClient <Flask 'click_api.app'>>
/opt/python/lib/python3.11/site-packages/flask/testing.py:116: AttributeError

To Reproduce
Steps to reproduce the behavior:

  1. Start a python container via docker run python:3.11-slim bash
  2. Install necessary dependencies: python -m pip install -U pytest-flask requests werkzeug
  3. Run some tests requiring client fixture. E.g. set up minimalistic app according to the package readme and create a test like that:
@pytest.mark.unit
def werk_test(client):
    assert client

Expected behavior
Either compatibility with the newest werkzeug version or pin to an older one.

Environment (please complete the following information):

  • Python Version [e.g. 3.8.5]: 3.11
  • pytest-flask version: 1.3.0
  • werkzeug version: 3.1.3

Thanks a lot! Let me know if I can be any of help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions