rembg/tests/test_remove.py
Daniel Gatis e7a8a209db add tests
2022-08-24 20:10:40 -03:00

21 lines
539 B
Python

from io import BytesIO
from pathlib import Path
from imagehash import average_hash
from PIL import Image
from rembg import remove
here = Path(__file__).parent.resolve()
def test_remove():
image = Path(here / ".." / "examples" / "animal-1.jpg").read_bytes()
expected = Path(here / ".." / "examples" / "animal-1.out.png").read_bytes()
actual = remove(image)
actual_hash = average_hash(Image.open(BytesIO(actual)))
expected_hash = average_hash(Image.open(BytesIO(expected)))
assert actual_hash == expected_hash