Skip to main content

Utilities for unit testing with images.

Project description

pyimagetest

Code style: black

pyimagetest provides utilities for unit testing with images.

pyimagetest.ImageTestcase is an ABC meant for double inheritance with unittest.Testcase. It adds the assertImagesAlmostEqual method. The compared image objects do not have to be from the same pyimagetest.ImageBackend. As long as the backend is known to pyimagetest.ImageTestcase it is inferred automatically.

Currently the following ImageBackends are supported off-the-shelf:

  • imageio
  • PIL

Custom backends can be added by subclassing ImageBackend.

Example usage

import unittest
import pyimagetest


class Tester(pyimagetest.ImageTestcase, unittest.TestCase):
    @property
    def default_test_image_file(self):
        return "path/to/default/test/image/file"

    def test_io(self):
        imageio_image = self.load_image("imageio")
        pil_image = self.load_image("PIL")
        self.assertImagesAlmostEqual(imageio_image, pil_image)

if __name__ == "__main__":
    unittest.main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyimagetest-0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

pyimagetest-0.1-py3-none-any.whl (16.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page