diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 32ae8ab..4fe99f3 100644
a
|
b
|
class Command(BaseCommand):
|
97 | 97 | if has_bz2: |
98 | 98 | compression_types['bz2'] = bz2.BZ2File |
99 | 99 | |
| 100 | fixture_file_found = False |
| 101 | |
100 | 102 | app_module_paths = [] |
101 | 103 | for app in get_apps(): |
102 | 104 | if hasattr(app, '__path__'): |
… |
… |
class Command(BaseCommand):
|
164 | 166 | open_method = compression_types[compression_format] |
165 | 167 | try: |
166 | 168 | fixture = open_method(full_path, 'r') |
| 169 | fixture_file_found = True |
167 | 170 | except IOError: |
168 | 171 | if verbosity >= 2: |
169 | 172 | self.stdout.write("No %s fixture '%s' in %s." % \ |
… |
… |
class Command(BaseCommand):
|
215 | 218 | raise CommandError( |
216 | 219 | "No fixture data found for '%s'. (File format may be invalid.)" % |
217 | 220 | (fixture_name)) |
| 221 | if not fixture_file_found: |
| 222 | self.stderr.write("Any fixture file couldn't be found for '%s'" % |
| 223 | fixture_label) |
218 | 224 | |
219 | 225 | # Since we disabled constraint checks, we must manually check for |
220 | 226 | # any invalid keys that might have been added |
diff --git a/tests/modeltests/fixtures/tests.py b/tests/modeltests/fixtures/tests.py
index f9b0ac8..a80ca72 100644
a
|
b
|
class FixtureLoadingTests(TestCase):
|
130 | 130 | ]) |
131 | 131 | |
132 | 132 | # Load a fixture that doesn't exist |
133 | | management.call_command('loaddata', 'unknown.json', verbosity=0, commit=False) |
| 133 | management.call_command('loaddata', 'unknown.json', verbosity=0, stderr=six.StringIO(), commit=False) |
134 | 134 | |
135 | 135 | # object list is unaffected |
136 | 136 | self.assertQuerysetEqual(Article.objects.all(), [ |
… |
… |
class FixtureLoadingTests(TestCase):
|
265 | 265 | |
266 | 266 | def test_unmatched_identifier_loading(self): |
267 | 267 | # Try to load db fixture 3. This won't load because the database identifier doesn't match |
268 | | management.call_command('loaddata', 'db_fixture_3', verbosity=0, commit=False) |
| 268 | management.call_command('loaddata', 'db_fixture_3', verbosity=0, stderr=six.StringIO(), commit=False) |
269 | 269 | self.assertQuerysetEqual(Article.objects.all(), []) |
270 | 270 | |
271 | | management.call_command('loaddata', 'db_fixture_3', verbosity=0, using='default', commit=False) |
| 271 | management.call_command('loaddata', 'db_fixture_3', verbosity=0, stderr=six.StringIO(), |
| 272 | using='default', commit=False) |
272 | 273 | self.assertQuerysetEqual(Article.objects.all(), []) |
273 | 274 | |
274 | 275 | def test_output_formats(self): |
diff --git a/tests/modeltests/fixtures_model_package/tests.py b/tests/modeltests/fixtures_model_package/tests.py
index d147fe6..68edd91 100644
a
|
b
|
from __future__ import unicode_literals
|
3 | 3 | from django.core import management |
4 | 4 | from django.db import transaction |
5 | 5 | from django.test import TestCase, TransactionTestCase |
| 6 | from django.utils import six |
6 | 7 | |
7 | 8 | from .models import Article, Book |
8 | 9 | |
… |
… |
class FixtureTestCase(TestCase):
|
93 | 94 | ) |
94 | 95 | |
95 | 96 | # Load a fixture that doesn't exist |
96 | | management.call_command("loaddata", "unknown.json", verbosity=0, commit=False) |
| 97 | management.call_command("loaddata", "unknown.json", verbosity=0, stderr=six.StringIO(), commit=False) |
97 | 98 | self.assertQuerysetEqual( |
98 | 99 | Article.objects.all(), [ |
99 | 100 | "Django conquers world!", |
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 678db4a..ce287dc 100644
a
|
b
|
class TestFixtures(TestCase):
|
428 | 428 | verbosity=2, |
429 | 429 | commit=False, |
430 | 430 | stdout=stdout_output, |
| 431 | stderr=six.StringIO() |
431 | 432 | ) |
432 | 433 | self.assertTrue("No xml fixture 'this_fixture_doesnt_exist' in" in |
433 | 434 | stdout_output.getvalue()) |
434 | 435 | |
| 436 | def test_loaddata_not_fixture_file(self): |
| 437 | stderr_output = six.StringIO() |
| 438 | management.call_command( |
| 439 | 'loaddata', |
| 440 | 'this_fixture_doesnt_exist', |
| 441 | commit=False, |
| 442 | stderr=stderr_output, |
| 443 | stdout=six.StringIO() |
| 444 | ) |
| 445 | |
| 446 | self.assertTrue("Any fixture file couldn't be found for 'this_fixture_doesnt_exist'" in |
| 447 | stderr_output.getvalue()) |
| 448 | |
435 | 449 | |
436 | 450 | class NaturalKeyFixtureTests(TestCase): |
437 | 451 | |