Skip to content
Snippets Groups Projects
Commit 7646ed70 authored by Sebastian Hahta's avatar Sebastian Hahta Committed by Nicolas Pope
Browse files

Enable python tests

parent 6982d519
No related branches found
No related tags found
No related merge requests found
[submodule "ext/nanogui"]
path = ext/nanogui
url = https://github.com/wjakob/nanogui.git
[submodule "SDK/C++/public/ext/pybind11"]
path = SDK/C++/public/ext/pybind11
[submodule "SDK/CPP/public/ext/pybind11"]
path = SDK/CPP/public/ext/pybind11
url = https://github.com/pybind/pybind11.git
......@@ -6,10 +6,15 @@ include(GNUInstallDirs)
option(WITH_OPENCV "Build with OpenCV wrapper" ON)
option(WITH_PYTHON "Build Python module" OFF)
option(WITH_TESTS "Enable unit tests" ON)
find_package( Eigen3 REQUIRED NO_MODULE )
find_package( Threads REQUIRED )
if (WITH_TESTS)
enable_testing()
endif()
if (WITH_OPENCV)
find_package( OpenCV REQUIRED )
endif()
......
Subproject commit 06b673a0daef1db4f921a19676a51abec6fb13e8
......@@ -32,13 +32,6 @@ target_include_directories(voltu_sdk_py PRIVATE .)
target_link_libraries(voltu_sdk_py PUBLIC voltu_sdk)
set_target_properties(voltu_sdk_py PROPERTIES OUTPUT_NAME voltu)
enable_testing()
find_package(Python3 COMPONENTS Interpreter)
function(add_python_test TEST_NAME TEST_SCRIPT)
add_test(NAME ${TEST_NAME}
COMMAND Python3::Interpreter -m unittest ${TEST_SCRIPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()
add_python_test(test_load tests/test_load.py)
if (WITH_TESTS)
add_subdirectory(tests)
endif()
#include "module.hpp"
#include <voltu/voltu.hpp>
#include <voltu/initialise.hpp>
#include <voltu/types/errors.hpp>
......@@ -15,6 +16,7 @@ void py_exceptions(pybind11::module& m) {
}
PYBIND11_MODULE(voltu, m) {
m.attr("version") = py::make_tuple(VOLTU_VERSION_MAJOR, VOLTU_VERSION_MINOR, VOLTU_VERSION_PATCH);
py_exceptions(m);
py_automatic_bindings(m);
}
find_package(Python3 COMPONENTS Interpreter)
function(add_python_test TEST_NAME TEST_SCRIPT)
add_test(NAME ${TEST_NAME}
COMMAND Python3::Interpreter -B -m unittest ${TEST_SCRIPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# binary module directory to PYTHONPATH
set_tests_properties(${TEST_NAME} PROPERTIES
ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/..)
endfunction()
add_python_test(TestLoad test_load.py)
import unittest
import os
import voltu
class LoadLibrary(unittest.TestCase):
def test_get_instance(self):
import voltu
self.assertIsNotNone(voltu.instance())
# second call to instance() returns None
#self.assertIsNotNone(voltu.instance())
# second call to instance() returns None; should
# return same instance instead?
# self.assertIsNotNone(voltu.instance())
def test_version(self):
major, minor, patch = voltu.version
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment