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


Release history Release notifications

This version

0.1

Download files

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

Files for pyimagetest, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyimagetest-0.1-py3-none-any.whl (16.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyimagetest-0.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page