File: test_grayfilter.py

package info (click to toggle)
libpillowfight 0.3.1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 88,872 kB
  • sloc: ansic: 3,542; python: 802; makefile: 114; sh: 16
file content (26 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import tempfile
import unittest

import PIL.Image

import pillowfight


class TestGrayFilter(unittest.TestCase):
    def test_grayfilter(self):
        with tempfile.NamedTemporaryFile(suffix='.png') as tmpfile:
            in_img = PIL.Image.open("tests/data/black_border_problem.png")
            out_img = pillowfight.unpaper_grayfilter(in_img)
            in_img.close()

            # beware of JPG compression
            self.assertEqual(out_img.mode, "RGB")
            out_img.save(tmpfile.name)
            out_img.close()
            out_img = PIL.Image.open(tmpfile.name)

        expected_img = PIL.Image.open(
            "tests/data/black_border_problem_grayfilter.png"
        )
        self.assertEqual(out_img.tobytes(), expected_img.tobytes())
        expected_img.close()