Commit f4879af2 authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
Browse files

Fixed a bug introduced by [9527] -- empty/invalid fixtures were no longer being reported.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9528 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 089ab18c
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -132,15 +132,17 @@ class Command(BaseCommand):
                                return
                            else:
                                fixture_count += 1
                                objects_in_fixture = 0
                                if verbosity > 0:
                                    print "Installing %s fixture '%s' from %s." % \
                                        (format, fixture_name, humanize(fixture_dir))
                                try:
                                    objects = serializers.deserialize(format, fixture)
                                    for obj in objects:
                                        object_count += 1
                                        objects_in_fixture += 1
                                        models.add(obj.object.__class__)
                                        obj.save()
                                    object_count += objects_in_fixture
                                    label_found = True
                                except (SystemExit, KeyboardInterrupt):
                                    raise
@@ -158,6 +160,17 @@ class Command(BaseCommand):
                                                 (full_path, traceback.format_exc())))
                                    return
                                fixture.close()
                                
                                # If the fixture we loaded contains 0 objects, assume that an
                                # error was encountered during fixture loading.
                                if objects_in_fixture == 0:
                                    sys.stderr.write(
                                        self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)" %
                                            (fixture_name)))
                                    transaction.rollback()
                                    transaction.leave_transaction_management()
                                    return
                                
                        except Exception, e:
                            if verbosity > 1:
                                print "No %s fixture '%s' in %s." % \