def test_disk_output_calls_cv_imwrite(self, mock_imwrite): [ x for x in self.disk.apply(pf.Image('hello', 'jpg', [[]]), 'some/path') ] self.assertTrue(mock_imwrite.called)
def test_disk_output_apply_doesnt_create_folder_if_it_exists( self, mock_mkdir): [ x for x in self.disk.apply(pf.Image('hello', 'jpg', [[]]), 'some/path') ] self.assertFalse(mock_mkdir.called)
def setUp(self): self.img_id = 'someID' self.img_data = np.random.randn(10, 10, 3) self.image = pf.Image(self.img_id, 'jpg', self.img_data) self.mask = pf.transform.ColorMask(pf.Placeholder(out_type=pf.Image), pf.Constant([None, None, None]))
def test_disk_output_yields_image(self): img = pf.Image('hello', 'jpg', [[]]) output = [x for x in self.disk.apply(img, 'some/path')] self.assertEqual(len(output), 1) self.assertIs(img, output[0])
def test_image_init_sets_id(self): img_id = 'hello' img = pf.Image(img_id, 'jpg', [[]]) self.assertEqual(img.id, img_id)
def setUp(self): self.img_id = 'some_id' self.ext = 'jpg' self.img = pf.Image(self.img_id, self.ext, [[]])
def test_image_init_defaults_colorspace_to_bgr(self): img = pf.Image('id', 'jpb', [[]]) self.assertEqual(img.color_space, 'bgr')
def test_image_init_sets_color_space(self): color_space = 'rgb' img = pf.Image('id', 'jpg', [[]], color_space) self.assertEqual(img.color_space, color_space)
def test_image_init_sets_img_mat(self): img_mat = [[]] img = pf.Image('id', 'jpg', img_mat) self.assertIs(img.img_mat, img_mat)
def test_image_init_sets_extension(self): img_ext = 'jpg' img = pf.Image('id', img_ext, [[]]) self.assertEqual(img.ext, img_ext)