samedi 17 février 2018

Django LiveServerTestCase with SQLite3

I am using LiveServerTestCase for functional tests with selenium in a Django app. I am using sqlite3 as a backend for local development, and I'm running the tests with a local development server on port 8081.

I wrote a test for user registration, and when I run this test more than once, I see that the test fails because my form throws an error saying the user already exists. When I delete the sqlite3 database file and run re-run migrations I can run the test again and it works fine (but running again will fail).

I thought that this class would use a new database each time a test within the class was run, but I am getting errors.

My question is:

Is there another way to run the tests with LiveServerTestCase so that I don't have to delete the sqlite3 database each time I want to run the test?

Aucun commentaire:

Enregistrer un commentaire