mercredi 13 janvier 2016

Convenient way to work with Flask's test client response headers

I use FlaskClient to test my Flask application. Basic example of such test is:

 with app.test_client() as c:
      rv = c.get('/?vodka=42')
      assert rv.headers.get('Set-Cookie') is not None

However, I want to check not only existence of Set-Cookie header, but also the actual value, including cookie=value pair, an expiration, a domain, etc. Is there a better way for doing this than using regular expressions? Although, for now I'm interested only in parsing Set-Cookie header, my question is more general (i.e it's about parsing any kind of standard HTTP headers).

Aucun commentaire:

Enregistrer un commentaire