Commit 3dd4e7d3 authored by David Thompson's avatar David Thompson
Browse files

Add a Python test to the smtk::model module.

parent b6f2a8f5
......@@ -108,6 +108,7 @@ if(SMTK_BUILD_PYTHON_WRAPPINGS AND Shiboken_FOUND)
if(SMTK_ENABLE_TESTING)
get_filename_component(SHIBOKEN_LIBRARY_PATH ${SHIBOKEN_LIBRARY} PATH)
add_subdirectory(attribute/PythonTesting)
add_subdirectory(model/PythonTesting)
add_subdirectory(view/PythonTesting)
endif(SMTK_ENABLE_TESTING)
......
set(smtkModelPythonTests
modelBodyCreate
)
find_package( PythonInterp 2.7 )
if( PYTHONINTERP_FOUND )
set(LIB_ENV_VAR "")
if(APPLE AND UNIX)
set(LIB_ENV_VAR "DYLD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
elseif(UNIX)
set(LIB_ENV_VAR "LD_LIBRARY_PATH=${SHIBOKEN_LIBRARY_PATH}")
endif()
set(SHIBOKEN_SMTK_PYTHON "")
if(UNIX)
set(SHIBOKEN_SMTK_PYTHON "${CMAKE_BINARY_DIR}:${SHIBOKEN_LIBRARY_PATH}")
endif()
foreach (test ${smtkModelPythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py)
set_tests_properties(${test}Py
PROPERTIES
ENVIRONMENT "PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}"
)
endforeach()
else()
message("could not find python interp")
endif()
"""
Demonstrate model construction from within Python.
"""
import os
import smtk
if __name__ == '__main__':
import sys
status = 0
try:
region = smtk.model.Link(smtk.model.CELL_ENTITY, 3)
f1 = smtk.model.Link(smtk.model.CELL_ENTITY, 2)
f2 = smtk.model.Link(smtk.model.CELL_ENTITY, 2)
f3 = smtk.model.Link(smtk.model.CELL_ENTITY, 2)
f4 = smtk.model.Link(smtk.model.CELL_ENTITY, 2)
mb = smtk.model.ModelBody()
u01 = mb.addLink(f1)
u02 = mb.addLink(f2)
u03 = mb.addLink(f3)
u04 = mb.addLink(f4)
region.appendRelation(u01).appendRelation(u02).appendRelation(u03).appendRelation(u04)
u00 = mb.addLink(region)
# Now verify that the faces refer back to the volume:
status = 0 if mb.findLink(u01).relations()[0] == u00 else 1
except Exception, ex:
print 'Exception:'
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print
print 'Exception: ', exc_type, fname, 'line', exc_tb.tb_lineno
print
print ex
print
status = -1
sys.exit(status)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment