pytest-dev / pytest-dev/pytest-flask
Sessions are empty when testing
Open
@northernSage is already working on this.
Since Mar 31, 2021.
- Dominant language
- Python
- Stars
- 499
- Forks
- 93
- PR merge metrics
- No merged PRs in 30d
Description
This doc expresses that we can access session without any extra context manager.
However the following code does not return any session key (session is empty):
from flask import Flask
import pytest
from flask import session
myapp = Flask('testing')
myapp.secret_key = 'secret'
myapp.debug = True
@myapp.route('/')
def home():
return session['message']
@pytest.fixture
def app():
return myapp
def test_home(client):
session['message'] = 'something'
response = client.get('/')
assert response.data == 'something'
Any hint on what we're missing here?
Thanks :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.