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:
committed by
Mariusz Felisiak
parent
2e48cf6bd9
commit
0e3b0da2e3
BIN
tests/fixtures/fixtures/fixture5.json.lzma
vendored
Normal file
BIN
tests/fixtures/fixtures/fixture5.json.lzma
vendored
Normal file
Binary file not shown.
BIN
tests/fixtures/fixtures/fixture5.json.xz
vendored
Normal file
BIN
tests/fixtures/fixtures/fixture5.json.xz
vendored
Normal file
Binary file not shown.
20
tests/fixtures/tests.py
vendored
20
tests/fixtures/tests.py
vendored
@@ -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'"
|
||||
|
||||
Reference in New Issue
Block a user