tests/fprintd: Use unittest assertions more often

This commit is contained in:
Marco Trevisan (Treviño)
2020-01-30 19:25:12 +01:00
committed by Bastien Nocera
parent 74577a6806
commit f2804921a3

View File

@ -270,7 +270,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
with Connection(self.sockaddr) as con: with Connection(self.sockaddr) as con:
mem = img.get_data() mem = img.get_data()
mem = mem.tobytes() mem = mem.tobytes()
assert len(mem) == img.get_width() * img.get_height() self.assertEqual(len(mem), img.get_width() * img.get_height())
encoded_img = struct.pack('ii', img.get_width(), img.get_height()) encoded_img = struct.pack('ii', img.get_width(), img.get_height())
encoded_img += mem encoded_img += mem
@ -348,11 +348,11 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
while not self._abort: while not self._abort:
ctx.iteration(True) ctx.iteration(True)
assert self._last_result == 'enroll-completed' self.assertEqual(self._last_result, 'enroll-completed')
self.device.EnrollStop() self.device.EnrollStop()
assert os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')) self.assertTrue(os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')))
# Finger is enrolled, try to verify it # Finger is enrolled, try to verify it
self.device.VerifyStart('(s)', 'any') self.device.VerifyStart('(s)', 'any')
@ -362,8 +362,8 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
self._abort = False self._abort = False
while not self._abort: while not self._abort:
ctx.iteration(True) ctx.iteration(True)
assert self._verify_stopped == True self.assertTrue(self._verify_stopped)
assert self._last_result == 'verify-no-match' self.assertEqual(self._last_result, 'verify-no-match')
self.device.VerifyStop() self.device.VerifyStop()
self.device.VerifyStart('(s)', 'any') self.device.VerifyStart('(s)', 'any')
@ -373,22 +373,22 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
self._abort = False self._abort = False
while not self._abort: while not self._abort:
ctx.iteration(True) ctx.iteration(True)
assert self._verify_stopped == False self.assertFalse(self._verify_stopped)
assert self._last_result == 'verify-swipe-too-short' self.assertEqual(self._last_result, 'verify-swipe-too-short')
# Try the correct print; will stop verification # Try the correct print; will stop verification
self.send_image('whorl') self.send_image('whorl')
self._abort = False self._abort = False
while not self._abort: while not self._abort:
ctx.iteration(True) ctx.iteration(True)
assert self._verify_stopped == True self.assertTrue(self._verify_stopped)
assert self._last_result == 'verify-match' self.assertEqual(self._last_result, 'verify-match')
# And delete the print(s) again # And delete the print(s) again
self.device.DeleteEnrolledFingers('(s)', 'testuser') self.device.DeleteEnrolledFingers('(s)', 'testuser')
assert not os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')) self.assertFalse(os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')))
self.device.Release() self.device.Release()
@ -404,16 +404,16 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
while not self._abort: while not self._abort:
ctx.iteration(True) ctx.iteration(True)
assert self._last_result == 'enroll-completed' self.assertEqual(self._last_result, 'enroll-completed')
self.device.EnrollStop() self.device.EnrollStop()
assert os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')) self.assertTrue(os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')))
# And delete the print(s) again using the new API # And delete the print(s) again using the new API
self.device.DeleteEnrolledFingers2() self.device.DeleteEnrolledFingers2()
assert not os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')) self.assertFalse(os.path.exists(os.path.join(self.state_dir, 'testuser/virtual_image/0/7')))
self.device.Release() self.device.Release()