vendredi 20 avril 2018

Flask Testing: Modify session for next request

I am trying to test my shopping cart part of my flask app. The test that fails is the following one:

# Set cart
with client.session_transaction() as sess:
    sess["cart"] = [1, 2]

# Remove item from cart
client.post("/cart/remove/2")

# Test cart
with client.session_transaction() as sess:
    resp = client.get("/")
    assert [1] == sess.get("cart")

The result of the last request is that the sessions still contains [1, 2]. I know that the actual code I'm testing works, because I've tested it manually before, so it must be something to do with how I use the session. Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire