How do you load test fixtures using the django-nose test runner?
#settings.test.py
INSTALLED_APPS += ('django_nose', )
TEST_RUNNER = 'django_nose.run_tests'
#appname/tests.py
from datetime import date,datetime, timedelta
from django.contrib.auth.models import User
from django.test.client import Client
from django.test import TestCase
class BetViewsTestCase(TestCase):
#files placed in appname/fixtures/restaurant.json, appname/fixtures/map.json
fixtures = ['authtestdata.json', 'restaurant.json', 'map.json']
In your setup method, just call:
management.call_command('loaddata', 'Category.json', verbosity=0)
Then in your teardown, call:
management.call_command('flush', verbosity=0, interactive=False)
You can import management from here:
from django.core import management
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