On Sat, May 23, 2009 at 12:59 AM, Stefan Tunsch <stun...@gmail.com> wrote:
>
> Hi!
>
> I have a fixture in json format, which I want to start using together
> with my test cases.
>
> I have deleted the data I didn't want from my development database and
> have dumped the data with the following command:
> manage.py dumpdata --exclude=contenttypes > myapp/fixtures/inicial.json
>
> I can also load this data to a fresh database, doing first a syncdb and
> then a loaddata command.
>
> But when I run my testcase, I get the following error:
>
>
> .Problem installing fixture 'inicial.json': Traceback (most recent call
> last):
>  File "C:\django-trunk\django\core\management\commands\loaddata.py",
> line 150,
> in handle
>    for obj in objects:
>  File "C:\django-trunk\django\core\serializers\json.py", line 41, in
> Deserializ
> er
>    for obj in PythonDeserializer(simplejson.load(stream)):
>  File "C:\django-trunk\django\utils\simplejson\__init__.py", line 298,
> in load
>    parse_constant=parse_constant, **kw)
>  File "C:\django-trunk\django\utils\simplejson\__init__.py", line 338,
> in loads
>
>    return _default_decoder.decode(s)
>  File "C:\django-trunk\django\utils\simplejson\decoder.py", line 326,
> in decode
>
>    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>  File "C:\django-trunk\django\utils\simplejson\decoder.py", line 344,
> in raw_de
> code
>    raise ValueError("No JSON object could be decoded")
> ValueError: No JSON object could be decoded
>
> The data seems to be loaded correctly to the test database, at least to
> some extent.
>
> How can I track down the error? Or can it be a bug in the deserializer
> code...

It _could_ be a bug in the deserializer code, but if I had to place a
bet, that wouldn't be where I would be looking. There is a fairly
extensive set of unit tests for the deserializers, and while I'm sure
that they are not infallible, any bugs that remain must be very well
hidden.

The "No JSON object could be decoded" error generally means that the
fixture itself is broken in some way - generally a formatting problem
of some kind, such as an extra comma or mismatched parentheses. Of
course, this could indicate a problem with the serializer, but without
details its hard to narrow this down.

I would suggest the following for debug:

 * Manually inspect the fixture and see if you can find anything
obviously un-JSONy.

 * Try loading the fixture manually (using manage.py loaddata) - this
will sometimes give you a little more detail on the location of an
error (such as a line number)

 * Try deleting segments of the fixture until you can get the fixture
to load successfully. For example, if the full fixture won't load, try
deleting the second half the entries in the fixture. If the fixture
gives the same error, then you know the problem is in the first half
of the fixture. Repeat until you have reduced the fixture to a single
(or small number) of entries that won't load.

If you can narrow down the source of the loading problem, we can look
into how it occurred, and how to prevent it happening again.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to