升级Werkzeug至2.0.3后仍遇Flask 'as_tuple'关键字参数错误
Flask测试API报错排查:
TypeError: EnvironBuilder.__init__() got an unexpected keyword argument 'as_tuple' 错误详情
运行API测试时触发如下错误:
if request is None: > builder = EnvironBuilder(*args, **kwargs) E TypeError: EnvironBuilder.__init__() got an unexpected keyword argument 'as_tuple'
相关测试代码
@pytest.fixture(autouse=True) def client(): app = my_app() with app.test_client() as client: yield client def test_new_func(client, monkeypatch): monkeypatch.setattr(UnitPricing, 'find_unit_price', find_unit_pricing) monkeypatch.setattr(FullPricing, 'find_full_price', find_full_pricing) response = client.post("/price/calc", json=input_payload) assert response.status_code == 200 assert json.loads(response.data) == output_data
当前环境依赖
> pip show Flask werkzeug Name: Flask Version: 2.0.2 Summary: A simple framework for building complex web applications. Home-page: https://palletsprojects.com/p/flask Author: Armin Ronacher Author-email: armin.ronacher@active-4.com License: BSD-3-Clause Location: c:\users\xyz\venv\lib\site-packages Requires: click, itsdangerous, Jinja2, Werkzeug Required-by: Flask-Session, Flask-SQLAlchemy --- Name: Werkzeug Version: 2.0.3 Summary: The comprehensive WSGI web application library. Home-page: https://palletsprojects.com/p/werkzeug/ Author: Armin Ronacher Author-email: armin.ronacher@active-4.com License: BSD-3-Clause Location: c:\users\xyz\venv\lib\site-packages Requires: Required-by: Flask
已尝试方案及问题
此前查到的解决方案建议固定Werkzeug版本为2.0.3,我的requirements.txt已配置该版本,当前环境也确实是Flask 2.0.2 + Werkzeug 2.0.3,但错误依然存在,求解决。
内容的提问来源于stack exchange,提问作者ninjacode
相关产品推荐
相关产品推荐

