tests/fprintd: Make assertFprintError to accept list of errors we accept

It can be used to check if any of the error that is passed is raised
This commit is contained in:
Marco Trevisan (Treviño)
2021-01-23 16:00:25 +01:00
parent 5acf13cf51
commit c8c543672d

View File

@ -308,9 +308,15 @@ class FPrintdTest(dbusmock.DBusTestCase):
os.environ['FP_DRIVERS_WHITELIST'] = self.device_driver
def assertFprintError(self, fprint_error):
if isinstance(fprint_error, list) or isinstance(fprint_error, tuple):
fprint_error = [ re.escape(e) for e in fprint_error ]
fprint_error = '({})'.format('|'.join(fprint_error))
else:
fprint_error = re.escape(fprint_error)
return self.assertRaisesRegex(GLib.Error,
re.escape('GDBus.Error:{}.Error.{}:'.format(
FPRINT_NAMESPACE, fprint_error)))
re.escape('GDBus.Error:{}.Error.'.format(FPRINT_NAMESPACE)) +
'{}:'.format(fprint_error))
def skipTestIfCanWrite(self, path):
try: