diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_re.py | 2 | ||||
-rw-r--r-- | Lib/test/test_unicode.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 0ea5a20..e9c07a0 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -468,7 +468,7 @@ class ReTests(unittest.TestCase): m[(0,)] with self.assertRaisesRegex(IndexError, 'no such group'): m[(0, 1)] - with self.assertRaisesRegex(KeyError, 'a2'): + with self.assertRaisesRegex(IndexError, 'no such group'): 'a1={a2}'.format_map(m) m = pat.match('ac') diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 506f071..341007b 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1278,6 +1278,13 @@ class UnicodeTest(string_tests.CommonTest, self.assertRaises(ValueError, '{}'.format_map, 'a') self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1}) + class BadMapping: + def __getitem__(self, key): + return 1/0 + self.assertRaises(KeyError, '{a}'.format_map, {}) + self.assertRaises(TypeError, '{a}'.format_map, []) + self.assertRaises(ZeroDivisionError, '{a}'.format_map, BadMapping()) + def test_format_huge_precision(self): format_string = ".{}f".format(sys.maxsize + 1) with self.assertRaises(ValueError): |