Beispiel #1
0
def _get_pdiff(example):
    img_path, ref_path, diff_path = example.img_path, example.ref_path, example.diff_path
    trace("generated image: " + img_path)

    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)
    else:
        ref_dir = dirname(ref_path)
        if not exists(ref_dir):
            os.makedirs(ref_dir)

        with open(ref_path, "wb") as f:
            f.write(ref)

        trace("saved reference: " + ref_path)

        example.pixels = image_diff(diff_path, img_path, ref_path)
        if example.pixels != 0:
            comment = "dimensions don't match" if example.pixels == -1 else white(
                "%.02f%%" % example.pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")
Beispiel #2
0
 def assert_is_valid(self):
     self.set_current_screenshot()
     if self.set_new_base:
         self.set_base_screenshot()
     image_diff_result = image_diff(self.diff_screenshot_path,
                                    self.base_screenshot_path,
                                    self.current_screenshot_path)
     if image_diff_result != 0:
         __tracebackhide__ = True
         raise ScreenshotMismatchError(
             "The current screenshot doesn't match the base image.")
 def is_valid(self):
     self.set_current_screenshot()
     if self.set_new_base:
         self.set_base_screenshot()
     image_diff_result = image_diff(self.diff_screenshot_path,
                                    self.base_screenshot_path,
                                    self.current_screenshot_path)
     if image_diff_result == 0:
         return True
     else:
         return False
 def assert_is_valid(self):
     self.set_current_screenshot()
     if self.set_new_base:
         self.set_base_screenshot()
     image_diff_result = image_diff(
         self.diff_screenshot_path,
         self.base_screenshot_path,
         self.current_screenshot_path
     )
     if image_diff_result != 0:
         __tracebackhide__ = True
         raise ScreenshotMismatchError("The current screenshot doesn't match the base image.")
Beispiel #5
0
 def is_valid(self):
     self.set_current_screenshot()
     if self.set_new_base:
         self.set_base_screenshot()
     image_diff_result = image_diff(
         self.diff_screenshot_path,
         self.base_screenshot_path,
         self.current_screenshot_path
     )
     if image_diff_result == 0:
         return True
     else:
         return False
Beispiel #6
0
def _get_pdiff(example):
    img_path, ref_path, diff_path = example.img_path, example.ref_path, example.diff_path
    trace("generated image: " + img_path)

    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)
    else:
        ref_dir = dirname(ref_path)
        if not exists(ref_dir):
            os.makedirs(ref_dir)

        with open(ref_path, "wb") as f:
            f.write(ref)

        trace("saved reference: " + ref_path)

        example.pixels = image_diff(diff_path, img_path, ref_path)
        if example.pixels != 0:
            comment = "dimensions don't match" if example.pixels == -1 else white("%.02f%%" % example.pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")