mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-8978: improve tarfile.open error message when lzma / bz2 are missing (GH-24850)
Automerge-Triggered-By: GH:pablogsal
This commit is contained in:
parent
8a37463989
commit
9aea31dedd
4 changed files with 19 additions and 2 deletions
|
|
@ -2283,6 +2283,18 @@ class MiscTest(unittest.TestCase):
|
|||
'SubsequentHeaderError', 'ExFileObject', 'main'}
|
||||
support.check__all__(self, tarfile, not_exported=not_exported)
|
||||
|
||||
def test_useful_error_message_when_modules_missing(self):
|
||||
fname = os.path.join(os.path.dirname(__file__), 'testtar.tar.xz')
|
||||
with self.assertRaises(tarfile.ReadError) as excinfo:
|
||||
error = tarfile.CompressionError('lzma module is not available'),
|
||||
with unittest.mock.patch.object(tarfile.TarFile, 'xzopen', side_effect=error):
|
||||
tarfile.open(fname)
|
||||
|
||||
self.assertIn(
|
||||
"\n- method xz: CompressionError('lzma module is not available')\n",
|
||||
str(excinfo.exception),
|
||||
)
|
||||
|
||||
|
||||
class CommandLineTest(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue