I'm developing a Django app and can't seem to get the first of my tests to run, due to an error associated with the fixtures. When I do "python manage.py test", I get this error:
stacktrace
Creating test database for alias 'default'...
E
======================================================================
ERROR: setUpClass (polladmin.tests.ModelsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/test/testcases.py", line 956, in setUpClass
'database': db_name,
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 60, in handle
self.loaddata(fixture_labels)
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 90, in loaddata
self.load_label(fixture_label)
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 141, in load_label
for obj in objects:
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/serializers/json.py", line 85, in Deserializer
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/serializers/json.py", line 79, in Deserializer
for obj in PythonDeserializer(objects, **options):
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/serializers/python.py", line 96, in Deserializer
Model = _get_model(d["model"])
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/core/serializers/python.py", line 166, in _get_model
return apps.get_model(model_identifier)
File "/Users/username/Documents/ratchit/venv/lib/python2.7/site-packages/django/apps/registry.py", line 201, in get_model
app_label, model_name = app_label.split('.')
DeserializationError: Problem installing fixture '/Users/username/Documents/ratchit/polladmin/fixtures/models.json': need more than 1 value to unpack
----------------------------------------------------------------------
Ran 0 tests in 0.006s
FAILED (errors=1)
Destroying test database for alias 'default'...
polladmin/tests.py
from django.test import TestCase
from models import *
class ModelsTestCase(TestCase):
fixtures = ['models.json']
def test_unique_title_for_polls(self):
""" Test that new event cannot use the same title as existing """
self.assertFalse(
Poll.unique_title("Drinks"),
"Duplicate event title not detected by Event.unique_title()")
polladmin/fixtures/models.json
[
{
"model": "event",
"fields": {
"pk": 1,
"title": "Monty Python at the Hollywood Bowl"
}
},
{
"model": "poll",
"fields": {
"event": 1,
"title": "Drinks"
}
},
{
"model": "poll",
"fields": {
"event": 1,
"title": "Food"
}
}
]
Aucun commentaire:
Enregistrer un commentaire