Testing#
Our goal is to make it easy for you to test your implementation of the Astronomical Image Display API (AIDA). There are two things you need to test:
An instance of your class should pass the test
isinstance(your_instance, ImageDisplayInterface). This ensures that your class has all of the attributes and methods in the interface.To test the functionality of your implementation, we provide the class
ImageAPITest. To use it, create a subclass ofImageAPITestin your test suite, and define a single class attributeimage_widget_class. See Example of using the test class for an example of how to do this.
These tests do not test the actual image display functionality of your package, nor do they test the behaviour of your package via your package’s user interface. You should check that behavior in whatever way is appropriate for your package.
Example of using the test class#
# All implementations of the ImageViewerInterface will need to import
# these to carry out the tests.
from astro_image_display_api import ImageViewerInterface, ImageAPITest # noqa: I001
# This import should be replaced with an import of your specific
# implementation of the ImageViewerInterface. If you keep the
# "as ImageViewer" part, then the test below will work without modification.
from astro_image_display_api.image_viewer_logic import ImageViewerLogic as ImageViewer
# You should not need to change the test below.
def test_instance():
# Make sure that the ImageViewer has all required methods and attributes
# defined in the ImageViewerInterface.
image = ImageViewer()
assert isinstance(image, ImageViewerInterface)
class TestViewer(ImageAPITest):
"""
Test whether the non-display aspects of the ImageViewer
implementation are correct.
"""
image_widget_class = ImageViewer