vendredi 29 mars 2019

Testing the content of a flash message in Python

I would like to test whether a flash message contains certain text. So I have the line:

response = tester.post('login',
        data=dict(
        username='test', password='lol'), follow_redirects=True)
assert 'Welcome back!' in response.data

This however fails with the error message:

 assert 'Welcome back!' in response.data
 TypeError: a bytes-like object is required, not 'str'

Does anyone understand what I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire