コード例 #1
0
    def test_finalize(self):
        collector = RenderingTaskCollector(paste=True)
        assert collector.finalize() is None

        img1 = self.temp_file_name("img1.png")
        make_test_img(img1)

        collector.add_img_file(img1)
        final_img = collector.finalize()
        assert isinstance(final_img, Image.Image)
        assert final_img.size == (10, 10)
        img2 = self.temp_file_name("img2.png")
        final_img.save(img2)

        assert compare_pil_imgs(img1, img2)
        collector.add_img_file(img2)
        final_img = collector.finalize()
        assert isinstance(final_img, Image.Image)
        img3 = self.temp_file_name("img3.png")
        final_img.save(img3)

        assert final_img.size == (10, 20)
        assert advance_verify_img(img3, 10, 20, (0, 0), (10, 10), img1, (0, 0))

        collector = RenderingTaskCollector(paste=False, width=10, height=10)
        collector.add_img_file(img1)

        make_test_img(img2, color=(0, 255, 0))
        collector.add_img_file(img2)
        make_test_img(img3, color=(0, 0, 255))
        final_img = collector.finalize()
        assert final_img.size == (10, 10)
コード例 #2
0
    def make_advance_verification(self, img_file, subtask_info, subtask_id,
                                  task):
        start_box = self._get_box_start(*self._get_part_img_size(subtask_info))
        logger.debug('testBox: {}'.format(start_box))
        cmp_file, cmp_start_box = self._get_cmp_file(img_file, start_box,
                                                     subtask_id, subtask_info,
                                                     task)
        logger.debug('cmp_start_box {}'.format(cmp_start_box))
        res_x, res_y = self._get_part_size(subtask_info)

        return advance_verify_img(img_file, res_x, res_y, start_box,
                                  self.verification_options.box_size, cmp_file,
                                  cmp_start_box)
コード例 #3
0
    def test_finalize(self):
        collector = RenderingTaskCollector()
        assert collector.finalize() is None

        img1 = self.temp_file_name("img1.png")
        make_test_img(img1)

        collector.add_img_file(img1)
        final_img = collector.finalize()
        assert isinstance(final_img, OpenCVImgRepr)
        assert final_img.img.shape[:2] == (10, 10)
        img2 = self.temp_file_name("img2.png")
        final_img.save(img2)

        assert compare_pil_imgs(img1, img2)
        collector.add_img_file(img2)
        final_img = collector.finalize()
        assert isinstance(final_img, OpenCVImgRepr)
        img3 = self.temp_file_name("img3.png")
        final_img.save(img3)

        assert final_img.img.shape[:2] == (20, 10)
        assert advance_verify_img(img3, 10, 20, (0, 0), (10, 10), img1, (0, 0))
コード例 #4
0
ファイル: test_imgcompare.py プロジェクト: U0001F3A2/golem
    def test_advance_verify_img(self):
        img_path = self.temp_file_name("path1.png")
        make_test_img(img_path)

        assert not advance_verify_img("not an image", 10, 10, (0, 0),
                                      (2, 2), img_path, (0, 0))
        assert not advance_verify_img(img_path, 10, 10, (0, 0),
                                      (2, 2), "not an image", (0, 0))

        assert advance_verify_img(img_path, 10, 10, (0, 0), (2, 2), img_path,
                                  (0, 0))

        assert not advance_verify_img(img_path, 10, 9, (0, 0),
                                      (2, 2), img_path, (0, 0))
        assert not advance_verify_img(img_path, 9, 10, (0, 0),
                                      (2, 2), img_path, (0, 0))
        assert not advance_verify_img(img_path, 10, 10, (0, 0),
                                      (0, 2), img_path, (0, 0))
        assert not advance_verify_img(img_path, 10, 10, (0, 0),
                                      (2, 0), img_path, (0, 0))
        assert not advance_verify_img(img_path, 10, 10, (0, 0),
                                      (11, 10), img_path, (0, 0))
        assert not advance_verify_img(img_path, 10, 10, (0, 0),
                                      (10, 11), img_path, (0, 0))

        exr_path = get_test_exr()

        assert advance_verify_img(exr_path, 10, 10, (0, 0), (2, 2), exr_path,
                                  (0, 0))
        exr_path2 = get_test_exr(alt=True)
        assert not advance_verify_img(exr_path, 10, 10, (0, 0),
                                      (2, 2), exr_path2, (0, 0))
        assert not advance_verify_img(exr_path, 10, 10, (0, 0),
                                      (2, 2), img_path, (0, 0))
        assert not advance_verify_img(img_path, 10, 10, (0, 0),
                                      (2, 2), exr_path, (0, 0))