Skip to content

Commit 1a1c12d

Browse files
committed
test(python): basic tests for _repr_png_ implementation of ImageBuf
Signed-off-by: glowies <[email protected]>
1 parent 149b481 commit 1a1c12d

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed
115 Bytes
Loading
858 Bytes
Loading

testsuite/python-imagebuf/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
outputs = [ "out.tif", "outtuple.tif",
1313
"outarray.tif", "outarrayB.tif", "outarrayH.tif",
1414
"perchan.exr", "multipart.exr",
15-
"out.txt" ]
15+
"out.txt", "valid_repr_png.png", "invalid_repr_png.png" ]
1616

69.1 KB
Binary file not shown.

testsuite/python-imagebuf/src/test_imagebuf.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ def write (image, filename, format=oiio.UNKNOWN) :
5858

5959

6060

61+
def test_repr_png () :
62+
# Test a valid 16 bit exr
63+
b = oiio.ImageBuf("src/AllHalfValues.exr")
64+
png = b._repr_png_()
65+
66+
with open("valid_repr_png.png", "wb") as f:
67+
f.write(png)
68+
69+
# Test an invalid image with null dimensions
70+
# create ImageBuf with x dimension as 0
71+
b = oiio.ImageBuf(oiio.ImageSpec(0,2,4,"float"))
72+
png = b._repr_png_()
73+
with open("invalid_repr_png.png", "wb") as f:
74+
f.write(png)
75+
76+
77+
6178
def test_perchannel_formats () :
6279
# Test writing per-channel formats with an ImageBuf
6380
b = oiio.ImageBuf(oiio.ImageSpec(2,2,4,"float"))
@@ -296,6 +313,7 @@ def test_copy_metadata() :
296313
test_multiimage ()
297314
test_uninitialized ()
298315
test_copy_metadata ()
316+
test_repr_png ()
299317

300318
print ("\nDone.")
301319
except Exception as detail:

0 commit comments

Comments
 (0)