Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress mypy error #2

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions test/unit/data/datatypes/test_images.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from typing import (
Any,
Type,
)

from galaxy.datatypes.images import (
Image,
Pdf,
Tiff,
)
from .util import (
get_input_files,
MockDataset,
)
from typing import Any, Type


# Define test decorator


def __test(image_cls: Type[Image], input_filename: str):

def decorator(test_impl):
Expand All @@ -20,7 +25,7 @@ def test():
with get_input_files(input_filename) as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])
image.set_meta(dataset)
image.set_meta(dataset) # type: ignore[arg-type]
test_impl(dataset.metadata)

return test
Expand All @@ -30,6 +35,7 @@ def test():

# Define test factory


def __create_test(image_cls: Type[Image], input_filename: str, metadata_key: str, expected_value: Any):

@__test(image_cls, input_filename)
Expand All @@ -41,6 +47,7 @@ def test(metadata):

# Define test utilities


def __assert_empty_metadata(metadata):
for key in (
"axes",
Expand Down Expand Up @@ -127,3 +134,11 @@ def test_tiff_multipage(metadata):
test_png_channels_3 = __create_test(Image, "im3_a.png", "channels", 3)
test_png_depth_0 = __create_test(Image, "im1_uint8.png", "depth", 0)
test_png_frames_1 = __create_test(Image, "im1_uint8.png", "frames", 1)


# Test with files that neither Pillow nor tifffile can open


@__test(Pdf, "454Score.pdf")
def test_unsupported_metadata(metadata):
__assert_empty_metadata(metadata)
Loading