示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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]))
示例#4
0
    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])
示例#5
0
    def test_image_init_sets_id(self):
        img_id = 'hello'

        img = pf.Image(img_id, 'jpg', [[]])

        self.assertEqual(img.id, img_id)
示例#6
0
    def setUp(self):
        self.img_id = 'some_id'
        self.ext = 'jpg'

        self.img = pf.Image(self.img_id, self.ext, [[]])
示例#7
0
    def test_image_init_defaults_colorspace_to_bgr(self):
        img = pf.Image('id', 'jpb', [[]])

        self.assertEqual(img.color_space, 'bgr')
示例#8
0
    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)
示例#9
0
    def test_image_init_sets_img_mat(self):
        img_mat = [[]]

        img = pf.Image('id', 'jpg', img_mat)

        self.assertIs(img.img_mat, img_mat)
示例#10
0
    def test_image_init_sets_extension(self):
        img_ext = 'jpg'

        img = pf.Image('id', img_ext, [[]])

        self.assertEqual(img.ext, img_ext)