From 0509148c2458a990cd0a7fd2d7cfbd45eb43e000 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Fri, 15 Feb 2019 23:33:21 +0000 Subject: [PATCH] Refs #30160 -- Made destination path a required argument of extract(). --- django/utils/archive.py | 4 ++-- tests/utils_tests/test_archive.py | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/django/utils/archive.py b/django/utils/archive.py index b26924cc2a..15326eb18c 100644 --- a/django/utils/archive.py +++ b/django/utils/archive.py @@ -40,7 +40,7 @@ class UnrecognizedArchiveFormat(ArchiveException): """ -def extract(path, to_path=''): +def extract(path, to_path): """ Unpack the tar or zip file at the specified path to the directory specified by to_path. @@ -83,7 +83,7 @@ class Archive: def __exit__(self, exc_type, exc_value, traceback): self.close() - def extract(self, to_path=''): + def extract(self, to_path): self._archive.extract(to_path) def list(self): diff --git a/tests/utils_tests/test_archive.py b/tests/utils_tests/test_archive.py index d58d211ae5..feb1f12f00 100644 --- a/tests/utils_tests/test_archive.py +++ b/tests/utils_tests/test_archive.py @@ -33,12 +33,6 @@ class ArchiveTester: archive.extract(self.tmpdir) self.check_files(self.tmpdir) - def test_extract_method_no_to_path(self): - os.chdir(self.tmpdir) - with Archive(self.archive_path) as archive: - archive.extract() - self.check_files(self.tmpdir) - def test_extract_function(self): extract(self.archive_path, self.tmpdir) self.check_files(self.tmpdir) @@ -59,11 +53,6 @@ class ArchiveTester: extract(self.archive_lead_path, self.tmpdir) self.check_files(self.tmpdir) - def test_extract_function_no_to_path(self): - os.chdir(self.tmpdir) - extract(self.archive_path) - self.check_files(self.tmpdir) - def check_files(self, tmpdir): self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, '1'))) self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, '2')))