summaryrefslogtreecommitdiffstats
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.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 325491f..df48fab 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -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")