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):
....
Helps you write better programs. Many developers from Python community heard of and used unit testing to test their projects and knew about boilerplate code with Python and Django unittest module. But Pytest suggests much more pythonic tests without boilerplate.
If you're using the PyCharm IDE, you can run unittest or pytest by following these steps: In the Project tool window, select the tests directory. On the context menu, choose the run command for unittest . For example, choose Run 'Unittests in my Tests…'.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With