vimalloc/flask-jwt-extended

"TypeError: __init__() got an unexpected keyword argument 'as_tuple'" while running tests

masch82 opened this issue · 1 comments

Hi,

when running the tests not via tox (e.g. I discovered it by importing the project into the IDE, installing via requirements file, then installing pytest and then running the tests).
A lot of the tests produce the following errors :

TypeError: init() got an unexpected keyword argument 'as_tuple'

FAILED tests/test_additional_claims_loader.py::test_additional_claims_in_access_token - TypeError: __init__() got an unexpected keyword argument 'as_tuple'
FAILED tests/test_asymmetric_crypto.py::test_asymmetric_cropto - TypeError: __init__() got an unexpected keyword argument 'as_tuple'
FAILED tests/test_blocklist.py::test_non_blocklisted_access_token[blocklist_type0] - TypeError: __init__() got an unexpected keyword argument 'as_tuple'
FAILED tests/test_claims_verification.py::test_successful_claims_validation[/protected1] - TypeError: __init__() got an unexpected keyword argument 'as_tuple'
...

Steps to reproduce :

  • Clone project
  • Create and activate a virtual environment
  • pip install -r requirements.txt
  • pip install pytest python-dateutil
  • Run pytest

The reason seems to be a recent change in werkzeug 2.1.0 and above, see e.g. here on stackoverflow

In tox, this does not happen, since it installs compatible versions by default (Flask 2.1.1 & Werkzeug 2.1.1) :

py39 installed: attrs==21.4.0,cffi==1.15.0,click==8.1.2,cryptography==36.0.2,Flask==2.1.1,Flask-JWT-Extended @ file:///.../Development/Python/test/flask-jwt-extended/.tox/.tmp/package/1/Flask-JWT-Extended-4.3.1.zip,importlib-metadata==4.11.3,iniconfig==1.1.1,itsdangerous==2.1.2,Jinja2==3.1.1,MarkupSafe==2.1.1,packaging==21.3,pluggy==1.0.0,py==1.11.0,pycparser==2.21,PyJWT==2.3.0,pyparsing==3.0.7,pytest==7.1.1,python-dateutil==2.8.2,six==1.16.0,tomli==2.0.1,Werkzeug==2.1.1,zipp==3.7.0

The problem seems to be that requirements.txt
still specifies and old version Flask==2.0.1 and by default when currently installing e.g. via pip to a virtual environment, it defaults to Werkzeug 2.1.1 which breaks things. So either in requirements.txt we would need to

  • Upgrade to a newer / recent Flask version that works together with newer versions of Werkzeug
  • Fix the Werkzeug version in requirements.txt to something that is compatible with the exact Flask version in requirements.txt ...

Fixed in 6d6ddca, let me know if you have any problems with that!