summaryrefslogtreecommitdiff
path: root/Lib/test/test_zipfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r--Lib/test/test_zipfile.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 955e540f96..76e2f647c6 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -9,6 +9,7 @@ import subprocess
import sys
import time
import unittest
+import unittest.mock as mock
import zipfile
@@ -1739,6 +1740,16 @@ class OtherTests(unittest.TestCase):
fp.seek(0, os.SEEK_SET)
self.assertEqual(fp.tell(), 0)
+ @requires_bz2
+ def test_decompress_without_3rd_party_library(self):
+ data = b'PK\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+ zip_file = io.BytesIO(data)
+ with zipfile.ZipFile(zip_file, 'w', compression=zipfile.ZIP_BZIP2) as zf:
+ zf.writestr('a.txt', b'a')
+ with mock.patch('zipfile.bz2', None):
+ with zipfile.ZipFile(zip_file) as zf:
+ self.assertRaises(RuntimeError, zf.extract, 'a.txt')
+
def tearDown(self):
unlink(TESTFN)
unlink(TESTFN2)