[Solved]-Is it possible to use fixtures from other apps in django's tests?


Apparently yes, any fixture can be loaded from any app as if it was in the same app, so be wary of what you name your fixtures. :/



For example, if you have two apps, one named for “App1” and the other named “App2”, and the structure of your project is something like this:


this is a imaginary scenario, and you want to write test script for “APP2” but your test script may need the data from “APP1”, in other words you need the fixtures in “APP1”

from APP1.models.app_1_model import *
class TestApp2(TestCase):
   fixtures = ['fixture_app2_number_1','fixture_app2_number_2','fixture_app2_number_3','fixture_app1_number_1']
   def test_function_one(self):

as you saw, just write the fixture name of “APP1” in the fixtures list, very intelligent and easy.

Leave a comment