Skip to content

Commit

Permalink
add save test for callable data
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjuleee committed Nov 13, 2023
1 parent 1a0dcfa commit 9dce88f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/unit/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np

import datumaro.util.image as image_module
from datumaro.components.media import ImageFromData

from ..requirements import Requirements, mark_requirement

Expand Down Expand Up @@ -71,3 +72,15 @@ def test_save_image_can_create_dir(self):
path = osp.join(test_dir, "some", "path.jpg")
image_module.save_image(path, np.ones((5, 4, 3)), create_dir=True)
self.assertTrue(osp.isfile(path))

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_save_callable_image(self):
with TestDir() as test_dir:
path = osp.join(test_dir, "some", "path.jpg")

def callable_data():
return np.ones((5, 4, 3))

image = ImageFromData(data=callable_data)
image.save(path)
self.assertTrue(osp.isfile(path))

0 comments on commit 9dce88f

Please sign in to comment.