Django test not loading fixture data

后端 未结 4 1077
面向向阳花
面向向阳花 2021-02-07 06:40

I have written tests for a Django project that i am working on, but one particular fixture fails to load. The fixture is generated using dumpdata and i havent fiddled with it at

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-07 06:58

    Import the TestCase from django.test:

    from django.test import TestCase
    
    class test_something(TestCase):
        fixtures = ['one.json', 'two.json']
        ...
    
    • Not: import unittest
    • Not: import django.utils.unittest
    • But: import django.test

    That's a day of frustration right there. Stop complaining - it's in the docs :-/

提交回复
热议问题