I'm using django-rest-framework to create an API. I'm using the framework's APITestCase
to test some of my endpoints.
The documentation doesn't specify a way to load fixtures and the traditional fixtures= ['initial_data.json']
doesn't seem to be working.
How would one go about loading fixtures?
The way you describe should work also. Make sure you're declaring the fixtures in the test class. An example below:
class MyViewsTestCase(APITestCase):
fixtures = ['some_testdata.json']
def test_random_thingy(self):
variable = 'hello'
self.assertEqual(variable, 'hello')
Every time you're test is run, the fixtures will be loaded in and removed after the test has run.
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