From 0697188084bf61b28f258fbbe867e1010d679b3e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 29 Jul 2024 13:40:16 +0300 Subject: gh-122311: Add more tests for error messages in pickle (GH-122373) --- Lib/test/pickletester.py | 235 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 185 insertions(+), 50 deletions(-) diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index a2b49e6..3c936b3 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -1229,24 +1229,38 @@ class AbstractUnpickleTests: self.assertIs(unpickler.find_class('os.path', 'join'), os.path.join) self.assertIs(unpickler4.find_class('builtins', 'str.upper'), str.upper) - with self.assertRaises(AttributeError): + with self.assertRaisesRegex(AttributeError, + r"module 'builtins' has no attribute 'str\.upper'|" + r"Can't get attribute 'str\.upper' on \.spam'|" + r"Can't get attribute 'log\.\.spam' on .spam') - with self.assertRaises(AttributeError): + with self.assertRaisesRegex(AttributeError, + r"Can't get local attribute 'log\.\.spam' on .spam') - with self.assertRaises(AttributeError): + with self.assertRaisesRegex(AttributeError, + "module 'math' has no attribute ''|" + "Can't get attribute '' on )' + r' must return (a )?string or tuple') with self.assertRaisesRegex( ValueError, 'The reducer just failed'): -- cgit v0.12