Reputation: 1172
I have an app called pta.apps.users which is loaded in the Loaded apps setting in my settings.py.
The app works fine, I now want to test it and have placed json files in the fixtures directory inside my users app.
I have a test which runs fine but the fixtures wont load.
from django.test import TestCase
from django.test.client import Client
from BeautifulSoup import BeautifulSoup
class SimpleTest(TestCase):
fixtures = ['user.json']
def setUp(self):
self.c = Client()
def test_parse_html(self):
response = self.c.get('/users/login/', follow=True)
soup = BeautifulSoup(response.content)
self.assertEquals(soup.h1.renderContents(), 'Entrance')
I just get No fixtures found.
in my output. I am using Django 1.2.1. Any help would be appreciatted.
Upvotes: 1
Views: 722
Reputation: 154
To load a fixture, I'm pretty sure you have to either call it manually with loaddata
(like you did), or call it specifically "initial_data," e.g. initial_data.sql
, initial_data.json
, initial_data.yaml
, etc., and store it in the fixtures directory of your app.
Upvotes: 0
Reputation: 3282
where did you placed your fixtures? The fixtures should placed in your app directory:
MyApp/fixtures/user.json
Or you hav to specify a external fixtures directory in your settings.py:
FIXTURE_DIRS = (
'external_fixtures/',
)
Upvotes: 1