From caac995774d2e89f4ce8bc5ed956a425d4be7382 Mon Sep 17 00:00:00 2001 From: Wonju Lee Date: Mon, 13 Nov 2023 20:05:20 +0900 Subject: [PATCH 1/2] mocking video_frame data --- tests/integration/cli/test_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration/cli/test_utils.py b/tests/integration/cli/test_utils.py index b6097f229b..999bee3405 100644 --- a/tests/integration/cli/test_utils.py +++ b/tests/integration/cli/test_utils.py @@ -1,7 +1,9 @@ import os import os.path as osp from unittest.case import TestCase +from unittest.mock import PropertyMock, patch +import numpy as np import pytest from datumaro.components.media_manager import MediaManager @@ -14,11 +16,12 @@ from tests.utils.test_utils import run_datum as run -@pytest.mark.xfail(reason="This test is flaky so that can fail randomly") class VideoSplittingTest: @mark_requirement(Requirements.DATUM_GENERAL_REQ) @scoped - def test_can_split_video(self): + @patch("datumaro.components.media.VideoFrame.data", new_callable=PropertyMock) + def test_can_split_video(self, mock_video_frame_data): + mock_video_frame_data.return_value = np.full((32, 32, 3), fill_value=0, dtype=np.uint8) on_exit_do(MediaManager.get_instance().clear) test_dir = scope_add(TestDir()) From 9ac8cac4dd18cc3178e7ffe79aaaaee2c2af2f32 Mon Sep 17 00:00:00 2001 From: Wonju Lee Date: Mon, 13 Nov 2023 20:11:24 +0900 Subject: [PATCH 2/2] fix typo --- src/datumaro/components/media.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datumaro/components/media.py b/src/datumaro/components/media.py index adc685e33a..e25fba972d 100644 --- a/src/datumaro/components/media.py +++ b/src/datumaro/components/media.py @@ -1084,7 +1084,7 @@ def from_bytes(cls, *args, **kwargs): raise DatumaroError(f"Please use a factory function '{cls.__name__}.from_image_roi_pairs'.") -class MosiacImageFromData(FromDataMixin, MosaicImage): +class MosaicImageFromData(FromDataMixin, MosaicImage): def save( self, fp: Union[str, io.IOBase], @@ -1104,7 +1104,7 @@ def save( save_image(fp, data, ext=new_ext, crypter=crypter) -class MosaicImageFromImageRoIPairs(MosiacImageFromData): +class MosaicImageFromImageRoIPairs(MosaicImageFromData): def __init__(self, data: List[ImageWithRoI], size: Tuple[int, int]) -> None: def _get_mosaic_img() -> np.ndarray: h, w = self.size