Skip to content

Sessions are empty when testing #69

Description

@vinyll

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 :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions