Exemple #1
0
 def test_modify(self):
     POS = (0, 0)
     for img in imgs.get_imgs():
         pixel = imgs.wrap(img.getpixel(POS))[0]
         evald_img = analyse.modify('value ^ 177', img)
         evald_pixel = imgs.wrap(evald_img.getpixel(POS))[0]
         self.assertEqual(evald_pixel, pixel ^ 177)
Exemple #2
0
 def test_modify(self):
     POS = (0, 0)
     for img in imgs.get_imgs():
         pixel = imgs.wrap(img.getpixel(POS))[0]
         evald_img = analyse.modify('value ^ 177', img)
         evald_pixel = imgs.wrap(evald_img.getpixel(POS))[0]
         self.assertEqual(evald_pixel, pixel ^ 177)
Exemple #3
0
 def test_match_imgs(self):
     """Test if the automatic conversion between modes works as intended."""
     images = imgs.get_imgs()
     for img in images:
         with imgs.TempFile(img) as img1_path:
             with imgs.TempFile(images[0]) as img2_path:
                 img1, img2 = analyse.match_imgs(img1_path, img2_path)
                 self.assertEqual(img1.mode, img2.mode)
Exemple #4
0
 def test_diffed_imgs_unequal_bounds(self):
     """Do not detect changes outside comparison bounds."""
     for img in imgs.get_imgs():
         diff_img = img.crop(box=(0, 0, 50, 50))
         diff_color = imgs.sub_from_color(img.color, 20)
         img.putpixel(xy=(60, 60), value=diff_color)
         differences = list(analyse.diffed_imgs(img, diff_img))
         self.assertEqual(0, len(differences))
Exemple #5
0
 def test_match_imgs(self):
     """Test if the automatic conversion between modes works as intended."""
     images = imgs.get_imgs()
     for img in images:
         with imgs.TempFile(img) as img1_path:
             with imgs.TempFile(images[0]) as img2_path:
                 img1, img2 = analyse.match_imgs(img1_path, img2_path)
                 self.assertEqual(img1.mode, img2.mode)
Exemple #6
0
 def test_diffed_imgs_unequal_bounds(self):
     """Do not detect changes outside comparison bounds."""
     for img in imgs.get_imgs():
         diff_img = img.crop(box=(0, 0, 50, 50))
         diff_color = imgs.sub_from_color(img.color, 20)
         img.putpixel(xy=(60, 60), value=diff_color)
         differences = list(analyse.diffed_imgs(img, diff_img))
         self.assertEqual(0, len(differences))
Exemple #7
0
 def test_find_diffs(self):
     DIFF_POS = (20, 20)
     for img in imgs.get_imgs():
         diff_color = imgs.sub_from_color(img.color, 12)
         diff_img = img.copy()
         diff_img.putpixel(DIFF_POS, diff_color)
         with imgs.TempFile() as path:
             analyse.find_diffs(img, diff_img, out_path=path)
             out_img = Image.open(path)
             self.assertEqual((255, 0, 0), out_img.getpixel(DIFF_POS))
             self.assertEqual((0, 0, 0), out_img.getpixel((0, 0)))
Exemple #8
0
 def test_find_diffs(self):
     DIFF_POS = (20, 20)
     for img in imgs.get_imgs():
         diff_color = imgs.sub_from_color(img.color, 12)
         diff_img = img.copy()
         diff_img.putpixel(DIFF_POS, diff_color)
         with imgs.TempFile() as path:
             analyse.find_diffs(img, diff_img, out_path=path)
             out_img = Image.open(path)
             self.assertEqual((255, 0 , 0), out_img.getpixel(DIFF_POS))
             self.assertEqual((0, 0, 0), out_img.getpixel((0, 0)))
Exemple #9
0
 def test_diffed_imgs(self):
     """Introduce one difference and check if it gets detected."""
     DIFF_POS = (50, 50)
     for img in imgs.get_imgs():
         diff_color = imgs.sub_from_color(img.color, 20)
         diff_img = img.copy()
         diff_img.putpixel(DIFF_POS, diff_color)
         differences = list(analyse.diffed_imgs(img, diff_img))
         self.assertEqual(1, len(differences))
         pos, img_pixel, diff_img_pixel = differences[0]
         self.assertEqual(DIFF_POS, pos)
         self.assertEqual(diff_color, diff_img_pixel)
         self.assertEqual(img.color, img_pixel)
Exemple #10
0
 def test_diffed_imgs(self):
     """Introduce one difference and check if it gets detected."""
     DIFF_POS = (50, 50)
     for img in imgs.get_imgs():
         diff_color = imgs.sub_from_color(img.color, 20)
         diff_img = img.copy()
         diff_img.putpixel(DIFF_POS, diff_color)
         differences = list(analyse.diffed_imgs(img, diff_img))
         self.assertEqual(1, len(differences))
         pos, img_pixel, diff_img_pixel = differences[0]
         self.assertEqual(DIFF_POS, pos)
         self.assertEqual(diff_color, diff_img_pixel)
         self.assertEqual(img.color, img_pixel)
Exemple #11
0
 def test_modify_output(self):
     img = imgs.get_imgs()[0]
     with imgs.TempFile() as tmp_path:
         analyse.modify('value ^ 177', img, out_path=tmp_path)
         self.assertTrue(os.path.isfile(tmp_path))
Exemple #12
0
 def test_diffed_imgs_equal_imgs(self):
     """Don't yield a difference on two equal images."""
     for img in imgs.get_imgs():
         differences = list(analyse.diffed_imgs(img, img.copy()))
         self.assertEqual(0, len(differences))
Exemple #13
0
 def test_modify_output(self):
     img = imgs.get_imgs()[0]
     with imgs.TempFile() as tmp_path:
         analyse.modify('value ^ 177', img, out_path=tmp_path)
         self.assertTrue(os.path.isfile(tmp_path))
Exemple #14
0
 def test_diffed_imgs_equal_imgs(self):
     """Don't yield a difference on two equal images."""
     for img in imgs.get_imgs():
         differences = list(analyse.diffed_imgs(img, img.copy()))
         self.assertEqual(0, len(differences))