Example #1
0
def test_GdalImageReader_usable():
    """
    Test that GdalImageReader class reports as usable when GDAL is importable.
    """
    # Mock module value of ``osgeo`` to something not None to simulate
    # something having been imported.
    with mock.patch.dict('smqtk_image_io.impls.image_reader.gdal_io.__dict__',
                         {'osgeo': object()}):
        assert GdalImageReader.is_usable() is True
Example #2
0
def test_GdalImageReader_not_usable_missing_osgeo():
    """
    Test that class reports as not usable when GDAL is not importable (set
    to None in module).
    """
    # Catch expected warnings to not pollute output.
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', category=UserWarning)

        # Mock module value of ``osgeo`` to None.
        with mock.patch.dict(
                'smqtk_image_io.impls.image_reader.gdal_io.__dict__',
            {'osgeo': None}):
            assert GdalImageReader.is_usable() is False
Example #3
0
    """
    Test that class reports as not usable when GDAL is not importable (set
    to None in module).
    """
    # Catch expected warnings to not pollute output.
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', category=UserWarning)

        # Mock module value of ``osgeo`` to None.
        with mock.patch.dict(
                'smqtk_image_io.impls.image_reader.gdal_io.__dict__',
            {'osgeo': None}):
            assert GdalImageReader.is_usable() is False


@pytest.mark.skipif(not GdalImageReader.is_usable(),
                    reason="GdalImageReader implementation is not usable in "
                    "the current environment.")
class TestGdalImageReader(unittest.TestCase):
    """
    Tests for ``GdalImageReader`` class.

    If this was not skipped, ``osgeo`` must have been importable.
    """
    def test_init_default(self):
        """
        Test that construction with default parameters works.
        """
        GdalImageReader()

    def test_init_bad_load_method(self):