Commit bf2a9489 authored by Laurent Claustre's avatar Laurent Claustre

Merge branch '39-add-python-tests-to-the-test-suits' into 'master'

Resolve "Add python tests to the test suits"

Closes #39

See merge request !57
parents 3b4e4b45 baa84f06
Pipeline #3184 passed with stages
in 1 minute and 42 seconds
......@@ -32,7 +32,7 @@ test-python2 :
script:
- update-alternatives --set python /usr/bin/python2.7
- cd build/
- ctest --timeout 10
- ctest --timeout 10 --output-on-failure
test-python3 :
stage: test
......@@ -41,4 +41,4 @@ test-python3 :
script:
- update-alternatives --set python /usr/bin/python3.4
- cd build/
- ctest --timeout 10
- ctest --timeout 10 --output-on-failure
......@@ -553,8 +553,8 @@ if(LIMA_ENABLE_PYTHON)
${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/sip)
target_link_libraries(python_module_limacore limacore)
install(FILES python/__init__.py DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima")
install(FILES common/python/__init__.py common/python/Debug.py DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Core")
add_custom_command(TARGET lima${NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/python/Lima ${CMAKE_BINARY_DIR}/python/Lima)
install(DIRECTORY python/Lima/ DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima")
endif()
#--------------------------------------------------------------------------------
......
......@@ -49,6 +49,7 @@ endif()
if (LIMA_ENABLE_PYTHON)
limatools_run_sip_for_camera(${NAME})
add_custom_command(TARGET lima${NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/python ${CMAKE_BINARY_DIR}/python/Lima/Simulator)
install(FILES python/__init__.py DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Simulator")
endif()
......
......@@ -25,3 +25,6 @@ if (NOT WIN32)
set(test_src ${test_src} test_simulator_hwbuffersave test_simulator_framebuilder)
endif()
limatools_run_camera_tests("${test_src}" ${NAME})
set(python_test_src test_prepare_timeout)
limatools_run_camera_python_tests("${python_test_src}" ${NAME})
......@@ -98,7 +98,7 @@ class TestControl:
image = self.ct_control.ReadImage(last_img_ready)
time.sleep(self.sleep_time)
deb.Always('Forcing read frame %d memory' % last_img_ready)
data = ' ' + image.buffer.tostring()
data = b' ' + image.buffer.tostring()
class TestControlAutoSync:
......@@ -160,12 +160,12 @@ def main(argv):
try:
test_control.start(exp_time, nb_frames, prepare_timeout,
sleep_time)
except Core.Exception, e:
except Core.Exception as e:
if err in e.args[0]:
ok = True
deb.Always('Got good exception: %s' % e)
if not ok:
raise RuntimeError, 'Expected exception: %s' % err
raise RuntimeError('Expected exception: %s' % err)
if __name__ == '__main__':
main(sys.argv)
......@@ -46,6 +46,23 @@ function(limatools_run_camera_tests test_src cam_name)
endfunction()
function(limatools_run_camera_python_tests test_src cam_name)
foreach(file ${test_src})
add_test(NAME ${file}
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${file}.py)
if(WIN32)
# Add the dlls to the %PATH%
string(REPLACE ";" "\;" ESCAPED_PATH "$ENV{PATH}")
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PATH=${ESCAPED_PATH}\;$<SHELL_PATH:$<TARGET_FILE_DIR:limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:lima${cam_name}>>;PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/python>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_lima${cam_name}>>")
else()
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/python>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_limacore>>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_processlib>>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_lima${cam_name}>>")
endif()
endforeach(file)
endfunction()
function(limatools_run_sip_for_camera cam_name)
......
import sys
from Lima import processlib as Processlib
sys.modules['processlib'] = sys.modules['Lima.processlib']
sys.modules['Lima.processlib'] = None
from Lima.limacore import *
sys.modules['limacore'] = sys.modules['Lima.limacore']
sys.modules['Lima.limacore'] = None
from Lima.Debug import *
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