Closed Kulv3r closed 7 years ago
I don't think this is related to webtest. I'm not a flask user but maybe fixtures are reset for each test and the "account" fixture create the table so the table does not exist in the second test.
It was my bad. Solved the problem. It wasn't obvious for me that i need to pass a fixture as an argument to the test to have the fixture's table created.
So, for anyone around stumbling with similar problem, the solution is to explicitly add the fixture to your args, i.e. in my case:
def test_open_settings_invalid_account(
self,
account, # <-- ADD THIS FIXTURE to have the "accounts" table created.
testapp
):
url = url_for('account.settings', account_slug='lalala')
testapp.get(url, status=404)
I'm writing some tests for my Flask 0.12.1 with WebTest 2.0.27, and stuck with a weird error.
This view:
being tested by this code:
works fine for the first test, but fails weirdly for the 2nd:
i.e. "sqlite3.OperationalError: no such table: account". The table is of course there. As far as i get it, it uses the wrong context maybe, but i dunno why.