1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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 <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2021-10-24 15:18:05 +13:00 committed by Jule Anger
parent de24916a82
commit b919246c55

View File

@ -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: