Example #1
0
 def test_lookup_with_get_method_has_optional_default(self):
     d = ImageDict()
     obj1 = cv2.imread(path.join(_this_path, 'data', 'object.png'))
     obj2 = cv2.imread(path.join(_this_path, 'data', 'different_object.png'))
     lookup = cv2.imread(path.join(_this_path, 'data', 'lookup.png'))
     some_value = 1
     d[obj1] = some_value
     #use the same image in a lookup
     self.assertEqual(d.get(lookup), some_value)
     self.assertEqual(d.get(obj2, None), None)
Example #2
0
 def test_user_gets_a_confirmation_image_with_value(self):
     d = ImageDict()
     obj = cv2.imread(path.join(_this_path, 'data', 'object.png'))
     lookup = cv2.imread(path.join(_this_path, 'data', 'lookup.png'))
     value_spec = 1
     d[obj] = value_spec
     value, confirmation_image = d.get(lookup, return_confirmation = True)
     self.assertEqual(value, value_spec)
     self.assertTrue(hasattr(confirmation_image, 'shape'), 'Looks like the confirmation image is not a cv numpy image.')
     self.assertTrue(hasattr(confirmation_image, 'dtype'), 'Looks like the confirmation image is not a cv numpy image.')