From: Douglas Bagnall Date: Sun, 24 Oct 2021 02:18:05 +0000 (+1300) Subject: CVE-2020-25722 pytest: assertRaisesLdbError invents a message if you're lazy X-Git-Tag: ldb-2.5.0~226 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b919246c5523a511ad812c35c1a6b0eb4cc56259;p=thirdparty%2Fsamba.git CVE-2020-25722 pytest: assertRaisesLdbError invents a message if you're lazy This makes it easier to convert tests that don't have good messages. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564 Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 1b43359e3e8..ab366c7ed30 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -208,6 +208,8 @@ class TestCase(unittest.TestCase): def assertRaisesLdbError(self, errcode, message, f, *args, **kwargs): """Assert a function raises a particular LdbError.""" + if message is None: + message = f"{f.__name__}(*{args}, **{kwargs})" try: f(*args, **kwargs) except ldb.LdbError as e: