diff options
| author | Paolo Melchiorre <paolo@melchiorre.org> | 2020-05-15 09:40:42 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-05-15 11:30:28 +0200 |
| commit | 0e3b0da2e3ecee05e8b5eee763f444c94280dbcb (patch) | |
| tree | bdc8b0c5523a6ae0bf4631be1eca4068ed2e17c4 /tests/fixtures/tests.py | |
| parent | 2e48cf6bd9499f888a6cebf9f18c92717f1df55c (diff) | |
Fixed #31552 -- Added support for LZMA and XZ fixtures to loaddata.
Diffstat (limited to 'tests/fixtures/tests.py')
| -rw-r--r-- | tests/fixtures/tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
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): '<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'" |
