【发布时间】:2020-06-14 20:32:37
【问题描述】:
我无法获取之前通过flask.test_client 设置的cookie。
看看吧
我的灯具:
@pytest.fixture(scope='module')
def client():
app.config['TESTING'] = True
settings = Settings()
ctx = app.app_context()
ctx.push()
with app.test_client() as client:
yield client
ctx.pop()
os.system("rm -rf logs json")
还有测试:
def test_test(client):
# order cookie is set to url_encoded '{}' by default
to_set = {"1": 2}
client.set_cookie('order', json.dumps(to_set))
print(request.cookies.get('order')) # prints url-encoded '{}'
我做错了什么?我需要获取我之前为测试设置的 cookie。我该怎么做?
【问题讨论】:
标签: python python-3.x flask pytest