diff --git a/AUTHORS b/AUTHORS index 3b91851ae6..79676cb559 100644 --- a/AUTHORS +++ b/AUTHORS @@ -695,6 +695,7 @@ answer newbie questions, and generally made Django that much better: Owen Griffiths Pablo Martín Panos Laganakos + Paolo Melchiorre Pascal Hartig Pascal Varet Patrik Sletmo diff --git a/tests/fixtures/fixtures/fixture5.json.bz2 b/tests/fixtures/fixtures/fixture5.json.bz2 new file mode 100644 index 0000000000..046bfa5820 Binary files /dev/null and b/tests/fixtures/fixtures/fixture5.json.bz2 differ diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index 1e723a7b66..cac3ccabc4 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -21,6 +21,12 @@ from .models import ( PrimaryKeyUUIDModel, ProxySpy, Spy, Tag, Visa, ) +try: + import bz2 # NOQA + HAS_BZ2 = True +except ImportError: + HAS_BZ2 = False + class TestCaseFixtureLoadingTests(TestCase): fixtures = ['fixture1.json', 'fixture2.json'] @@ -540,6 +546,19 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): '', ]) + def test_compressed_loading_gzip(self): + management.call_command('loaddata', 'fixture5.json.gz', verbosity=0) + self.assertQuerysetEqual(Article.objects.all(), [ + '', + ]) + + @unittest.skipUnless(HAS_BZ2, 'No bz2 library detected.') + def test_compressed_loading_bz2(self): + management.call_command('loaddata', 'fixture5.json.bz2', verbosity=0) + self.assertQuerysetEqual(Article.objects.all(), [ + '', + ]) + def test_ambiguous_compressed_fixture(self): # The name "fixture5" is ambiguous, so loading raises an error. msg = "Multiple fixtures named 'fixture5'"