1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31552 -- Added support for LZMA and XZ fixtures to loaddata.

This commit is contained in:
Paolo Melchiorre
2020-05-15 09:40:42 +02:00
committed by Mariusz Felisiak
parent 2e48cf6bd9
commit 0e3b0da2e3
6 changed files with 40 additions and 5 deletions

View File

@@ -27,6 +27,12 @@ try:
except ImportError:
HAS_BZ2 = False
try:
import lzma # NOQA
HAS_LZMA = True
except ImportError:
HAS_LZMA = False
class TestCaseFixtureLoadingTests(TestCase):
fixtures = ['fixture1.json', 'fixture2.json']
@@ -558,6 +564,20 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
'<Article: WoW subscribers now outnumber readers>',
])
@unittest.skipUnless(HAS_LZMA, 'No lzma library detected.')
def test_compressed_loading_lzma(self):
management.call_command('loaddata', 'fixture5.json.lzma', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: WoW subscribers now outnumber readers>',
])
@unittest.skipUnless(HAS_LZMA, 'No lzma library detected.')
def test_compressed_loading_xz(self):
management.call_command('loaddata', 'fixture5.json.xz', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: WoW subscribers now outnumber readers>',
])
def test_ambiguous_compressed_fixture(self):
# The name "fixture5" is ambiguous, so loading raises an error.
msg = "Multiple fixtures named 'fixture5'"