Skip to content Skip to sidebar Skip to footer

Django Test Not Getting Model Object

I am just scratching the surface of testing in Django. Here is my testing code, inside tests.py: class AdvertisingTests( TestCase ): def test_get_ad( self ): '''

Solution 1:

Django tests create empty temporaty database see docs, which will be destroyed after tests.

To prepopulate testing DB with data you can use setUp method:

classAdvertisingTests(TestCase):defsetUp(self):
        Ad.objects.create(name="myAd")

Also you can use fixtures.

Post a Comment for "Django Test Not Getting Model Object"