14👍
✅
ilardm’s answer points in the right direction, specifically what you want is:
from django.core.management import call_command
call_command('loaddata', 'fixture_name.json')
Edit: But the correct way to include fixtures in test cases is like this:
class TestThis(TestCase):
fixtures = ['myfixture.json']
def setUp(self):
# Ready to test
- Cron parser and validation in python
- Django Rest Framework 3 Serializers on non-Model objects?
- POST with None data in Request Factory in Django
- Some strings not translated in django i18n module
1👍
Perhaps this link: http://testedwebdev.blogspot.ru/2012/05/django-shell-testing.html might help.
Source:stackexchange.com