Skip to content

Commit

Permalink
Add test for example python code in the pypi README.md
Browse files Browse the repository at this point in the history
Signed-off-by: Cary Phillips <[email protected]>
  • Loading branch information
cary-ilm committed Apr 9, 2024
1 parent 7a31cd5 commit f4bf60a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ BUILD_SHARED_LIBS = 'OFF'
CMAKE_POSITION_INDEPENDENT_CODE = 'ON'

[tool.cibuildwheel]
test-command = "ctest -R PyOpenEXR"
test-extras = ["test"]
test-command = "pytest -s {project}/src/wrappers/python/tests"
test-skip = ["*universal2:arm64"]
build-verbosity = 1

Expand Down
31 changes: 31 additions & 0 deletions src/wrappers/python/tests/test_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenEXR Project.
#

def test_readme():

import OpenEXR, Imath
from array import array

width = 10
height = 10
size = width * height

FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
h = OpenEXR.Header(width,height)
h['channels'] = {'R' : Imath.Channel(FLOAT),
'G' : Imath.Channel(FLOAT),
'B' : Imath.Channel(FLOAT),
'A' : Imath.Channel(FLOAT)}
o = OpenEXR.OutputFile("hello.exr", h)
r = array('f', [n for n in range(size*0,size*1)]).tobytes()
g = array('f', [n for n in range(size*1,size*2)]).tobytes()
b = array('f', [n for n in range(size*2,size*3)]).tobytes()
a = array('f', [n for n in range(size*3,size*4)]).tobytes()
channels = {'R' : r, 'G' : g, 'B' : b, 'A' : a}
o.writePixels(channels)
o.close()

0 comments on commit f4bf60a

Please sign in to comment.