Andreas
Andreas

Reputation: 1479

Django not creating a testdatabase when testing

I am running tests in my newly created Django project.

Normally I would expect to see a test database created for when tests are running. All tests are running fine, but I am seeing that my local database (for runserver use) is beeing used when running the tests.

A lot of excess data is beeing created in the wrong database. How can I get my test setup to use the normal test_dabasename setup again?

Im not sure what I have changed to make this happen and am totally stumped.

class TestRest(TestCase):
    def setUp(self):
        ...

    def test_allowed_to_get_list_authenticated(self):
        ....

Upvotes: 9

Views: 1532

Answers (1)

Andreas
Andreas

Reputation: 1479

Found it. Im such a bad programmer :(.

I imported from

from unittest.case import TestCase

when it should have been

from django.test import TestCase

This lead to no test database beeing created.

Upvotes: 18

Related Questions