Skip to content
Snippets Groups Projects
Commit 395636bb authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

add python tests

parent 7be19cc1
No related branches found
No related tags found
No related merge requests found
Pipeline #33529 passed
......@@ -37,7 +37,7 @@ public:
PY_API virtual void setPose(const Eigen::Matrix4f &) = 0;
PY_API virtual voltu::FramePtr getFrame() = 0;
PY_API PY_RV_LIFETIME_PARENT virtual voltu::FramePtr getFrame() = 0;
PY_API virtual voltu::PropertyPtr property(voltu::ObserverProperty) = 0;
};
......
......@@ -18,7 +18,7 @@ public:
PY_API PY_RV_LIFETIME_PARENT virtual voltu::PointCloudPtr getPointCloud(voltu::PointCloudFormat cloudfmt, voltu::PointFormat pointfmt) = 0;
virtual int64_t getTimestamp() = 0;
PY_API virtual int64_t getTimestamp() = 0;
};
typedef std::shared_ptr<Frame> FramePtr;
......
......@@ -31,3 +31,14 @@ 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)
# Python API generator
Dependencies
* python3-ply (cpp header parser)
* python3-ply (build only)
Build system uses Pybind11 to generate a python module. Most of the bindings are
automatically generated by gen.py script which is automatically called by CMake
......@@ -34,3 +34,4 @@ build. Several (empty) macros are used in headers to annoate Python API details.
* Static members
* Constructors
* Automatic documentation (Doxygen)
* Generator does not verify that shared_ptr<> is used consistently/correctly
import unittest
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())
if __name__ == '__main__':
unittest.main()
......@@ -21,6 +21,7 @@ public:
PYBIND11_TYPE_CASTER(voltu::ImageData, _("Image"));
bool load(py::handle src, bool convert) {
// TODO: C++ api should copy or otherwise take (shared) ownership
throw std::runtime_error("ImageData conversion python->c++ not supported");
return true;
}
......
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