mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-39359: [zipfile] add missing "pwd: expected bytes, got str" exception (GH-18031)
This commit is contained in:
parent
86b833badd
commit
91099e2544
3 changed files with 20 additions and 6 deletions
|
@ -2190,10 +2190,23 @@ class DecryptionTests(unittest.TestCase):
|
|||
self.assertEqual(self.zip2.read("zero"), self.plain2)
|
||||
|
||||
def test_unicode_password(self):
|
||||
self.assertRaises(TypeError, self.zip.setpassword, "unicode")
|
||||
self.assertRaises(TypeError, self.zip.read, "test.txt", "python")
|
||||
self.assertRaises(TypeError, self.zip.open, "test.txt", pwd="python")
|
||||
self.assertRaises(TypeError, self.zip.extract, "test.txt", pwd="python")
|
||||
expected_msg = "pwd: expected bytes, got str"
|
||||
|
||||
with self.assertRaisesRegex(TypeError, expected_msg):
|
||||
self.zip.setpassword("unicode")
|
||||
|
||||
with self.assertRaisesRegex(TypeError, expected_msg):
|
||||
self.zip.read("test.txt", "python")
|
||||
|
||||
with self.assertRaisesRegex(TypeError, expected_msg):
|
||||
self.zip.open("test.txt", pwd="python")
|
||||
|
||||
with self.assertRaisesRegex(TypeError, expected_msg):
|
||||
self.zip.extract("test.txt", pwd="python")
|
||||
|
||||
with self.assertRaisesRegex(TypeError, expected_msg):
|
||||
self.zip.pwd = "python"
|
||||
self.zip.open("test.txt")
|
||||
|
||||
def test_seek_tell(self):
|
||||
self.zip.setpassword(b"python")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue