Index: django/core/management/commands/loaddata.py
===================================================================
--- django/core/management/commands/loaddata.py	(revisión: 9808)
+++ django/core/management/commands/loaddata.py	(copia de trabajo)
@@ -1,4 +1,4 @@
-from django.core.management.base import BaseCommand
+from django.core.management.base import BaseCommand, CommandError
 from django.core.management.color import no_style
 from optparse import make_option
 import sys
@@ -73,12 +73,11 @@
                 if verbosity > 1:
                     print "Loading '%s' fixtures..." % fixture_name
             else:
-                sys.stderr.write(
-                    self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format." %
-                        (fixture_name, format)))
                 transaction.rollback()
                 transaction.leave_transaction_management()
-                return
+                error_msg = ("Problem installing fixture '%s': %s is not a known serialization format." %
+                             (fixture_name, format))
+                raise CommandError(error_msg)
 
             if os.path.isabs(fixture_name):
                 fixture_dirs = [fixture_name]
@@ -100,11 +99,11 @@
                         fixture = open(full_path, 'r')
                         if label_found:
                             fixture.close()
-                            print self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting." %
-                                (fixture_name, humanize(fixture_dir)))
                             transaction.rollback()
                             transaction.leave_transaction_management()
-                            return
+                            error_msg = ("Multiple fixtures named '%s' in %s. Aborting." %
+                                         (fixture_name, humanize(fixture_dir)))
+                            raise CommandError(error_msg)
                         else:
                             fixture_count += 1
                             objects_in_fixture = 0
@@ -128,24 +127,21 @@
                                 transaction.leave_transaction_management()
                                 if show_traceback:
                                     traceback.print_exc()
-                                else:
-                                    sys.stderr.write(
-                                        self.style.ERROR("Problem installing fixture '%s': %s\n" %
-                                             (full_path, ''.join(traceback.format_exception(sys.exc_type, 
-                                                 sys.exc_value, sys.exc_traceback))))) 
-                                return
+                                error_msg = ("Problem installing fixture '%s': %s\n" %
+                                             (full_path, ''.join(traceback.format_exception(sys.exc_type,
+                                                                                            sys.exc_value, sys.exc_traceback))))
+                                raise CommandError(error_msg)
                             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:
+                                error_msg = ("No fixture data found for '%s'. (File format may be invalid.)" %
+                                             fixture_name)
+                                raise CommandError(error_msg)
+                    except IOError:
                         if verbosity > 1:
                             print "No %s fixture '%s' in %s." % \
                                 (format, fixture_name, humanize(fixture_dir))
Index: tests/modeltests/fixtures/models.py
===================================================================
--- tests/modeltests/fixtures/models.py	(revisión: 9808)
+++ tests/modeltests/fixtures/models.py	(copia de trabajo)
@@ -73,8 +73,18 @@
 
 # Try to load fixture 2 using format discovery; this will fail
 # because there are two fixture2's in the fixtures directory
+>>> import sys
+>>> from StringIO import StringIO
+>>> savestderr = sys.stderr
+>>> sys.stderr = StringIO()
 >>> management.call_command('loaddata', 'fixture2', verbosity=0) # doctest: +ELLIPSIS
-Multiple fixtures named 'fixture2' in '...fixtures'. Aborting.
+Traceback (most recent call last):
+...
+SystemExit: 1
+>>> print sys.stderr.getvalue()
+Error: Multiple fixtures named 'fixture2' in '...fixtures'. Aborting.
+<BLANKLINE>
+>>> sys.stderr = savestderr
 
 >>> Article.objects.all()
 [<Article: Time to reform copyright>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>]
Index: tests/regressiontests/fixtures_regress/models.py
===================================================================
--- tests/regressiontests/fixtures_regress/models.py	(revisión: 9808)
+++ tests/regressiontests/fixtures_regress/models.py	(copia de trabajo)
@@ -100,29 +100,59 @@
 
 # redirect stderr for the next few tests...
 >>> import sys
+>>> from StringIO import StringIO
 >>> savestderr = sys.stderr
->>> sys.stderr = sys.stdout
+>>> sys.stderr = StringIO()
 
 # Loading data of an unknown format should fail
 >>> management.call_command('loaddata', 'bad_fixture1.unkn', verbosity=0)
-Problem installing fixture 'bad_fixture1': unkn is not a known serialization format.
+Traceback (most recent call last):
+...
+SystemExit: 1
+>>> print sys.stderr.getvalue()
+Error: Problem installing fixture 'bad_fixture1': unkn is not a known serialization format.
+<BLANKLINE>
 
 # Loading a fixture file with invalid data using explicit filename
+>>> sys.stderr.truncate(0)
 >>> management.call_command('loaddata', 'bad_fixture2.xml', verbosity=0)
-No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+Traceback (most recent call last):
+...
+SystemExit: 1
+>>> print sys.stderr.getvalue()
+Error: No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+<BLANKLINE>
 
 # Loading a fixture file with invalid data without file extension
+>>> sys.stderr.truncate(0)
 >>> management.call_command('loaddata', 'bad_fixture2', verbosity=0)
-No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+Traceback (most recent call last):
+...
+SystemExit: 1
+>>> print sys.stderr.getvalue()
+Error: No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+<BLANKLINE>
 
 # Loading a fixture file with no data returns an error
+>>> sys.stderr.truncate(0)
 >>> management.call_command('loaddata', 'empty', verbosity=0)
-No fixture data found for 'empty'. (File format may be invalid.)
+Traceback (most recent call last):
+...
+SystemExit: 1
+>>> print sys.stderr.getvalue()
+Error: No fixture data found for 'empty'. (File format may be invalid.)
+<BLANKLINE>
 
 # If any of the fixtures contain an error, loading is aborted
 # (Regression for #9011 - error message is correct)
+>>> sys.stderr.truncate(0)
 >>> management.call_command('loaddata', 'bad_fixture2', 'animal', verbosity=0)
-No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+Traceback (most recent call last):
+...
+SystemExit: 1
+>>> print sys.stderr.getvalue()
+Error: No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+<BLANKLINE>
 
 >>> sys.stderr = savestderr
 
