Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Thompson
SMTK
Commits
3dd4e7d3
Commit
3dd4e7d3
authored
Oct 29, 2013
by
David Thompson
Browse files
Add a Python test to the smtk::model module.
parent
b6f2a8f5
Changes
3
Show whitespace changes
Inline
Side-by-side
smtk/CMakeLists.txt
View file @
3dd4e7d3
...
...
@@ -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
)
...
...
smtk/model/PythonTesting/CMakeLists.txt
0 → 100644
View file @
3dd4e7d3
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
()
smtk/model/PythonTesting/modelBodyCreate.py
0 → 100644
View file @
3dd4e7d3
"""
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment