diff --git a/tests/core/core/reader/test__reader.py b/tests/core/core/reader/test__reader.py index e4250012a2..53fe876543 100644 --- a/tests/core/core/reader/test__reader.py +++ b/tests/core/core/reader/test__reader.py @@ -1,14 +1,43 @@ +import pytest +import numpy +import skimage.io as io from cellprofiler_core.reader import fill_readers, filter_active_readers from cellprofiler_core.constants.reader import ALL_READERS, AVAILABLE_READERS +from cellprofiler_core.image import MonochromeImage +from cellprofiler_core.utilities.pathname import pathname2url -def init_readers(): +@pytest.fixture(scope="module") +def readers(): + # init readers fill_readers() - print(ALL_READERS) - print("---") - filter_active_readers([x for x in ALL_READERS.keys() if "Google Cloud Storage" not in x], by_module_name=False) - print(AVAILABLE_READERS) + # do not test GCS Reader + filter_active_readers( + [x for x in ALL_READERS.keys() if "Google Cloud Storage" not in x], + by_module_name=False) + # post-filtered readers + return AVAILABLE_READERS + +def create_provider(img_data, path, rescale=True): + io.imsave(path, img_data) + + provider = MonochromeImage( + path.stem, # name + pathname2url(str(path)), # url + 0, # series + None, # index + None, # channel + rescale=rescale, + volume=False, + spacing=None, + z=None, + t=None + ) + return provider class TestReaders: - def test_readers(self): - init_readers() + def test_simple(self, readers, tmp_path): + img_data = numpy.array([0,0,0,0], dtype=numpy.dtype("uint8")).reshape(2,2) + provider = create_provider(img_data, tmp_path / "uint8_all_zero.tiff", rescale=True) + img = provider.provide_image(None) # img.pixel_data for array + print("Did the thing") \ No newline at end of file