From 0e3b0da2e3ecee05e8b5eee763f444c94280dbcb Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Fri, 15 May 2020 09:40:42 +0200 Subject: Fixed #31552 -- Added support for LZMA and XZ fixtures to loaddata. --- tests/fixtures/fixtures/fixture5.json.lzma | Bin 0 -> 157 bytes tests/fixtures/fixtures/fixture5.json.xz | Bin 0 -> 200 bytes tests/fixtures/tests.py | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 tests/fixtures/fixtures/fixture5.json.lzma create mode 100644 tests/fixtures/fixtures/fixture5.json.xz (limited to 'tests') diff --git a/tests/fixtures/fixtures/fixture5.json.lzma b/tests/fixtures/fixtures/fixture5.json.lzma new file mode 100644 index 0000000000..a41fdaa82f Binary files /dev/null and b/tests/fixtures/fixtures/fixture5.json.lzma differ diff --git a/tests/fixtures/fixtures/fixture5.json.xz b/tests/fixtures/fixtures/fixture5.json.xz new file mode 100644 index 0000000000..af2e82d5c1 Binary files /dev/null and b/tests/fixtures/fixtures/fixture5.json.xz differ diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index d46bf65c97..ac96c48734 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -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): '', ]) + @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(), [ + '', + ]) + + @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(), [ + '', + ]) + def test_ambiguous_compressed_fixture(self): # The name "fixture5" is ambiguous, so loading raises an error. msg = "Multiple fixtures named 'fixture5'" -- cgit v1.2.1