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

add python tests

parent 7be19cc1
Branches
Tags
No related merge requests found
Pipeline #33529 passed
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
PY_API virtual void setPose(const Eigen::Matrix4f &) = 0; 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; PY_API virtual voltu::PropertyPtr property(voltu::ObserverProperty) = 0;
}; };
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
PY_API PY_RV_LIFETIME_PARENT virtual voltu::PointCloudPtr getPointCloud(voltu::PointCloudFormat cloudfmt, voltu::PointFormat pointfmt) = 0; 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; typedef std::shared_ptr<Frame> FramePtr;
......
...@@ -31,3 +31,14 @@ target_include_directories(voltu_sdk_py PRIVATE .) ...@@ -31,3 +31,14 @@ target_include_directories(voltu_sdk_py PRIVATE .)
target_link_libraries(voltu_sdk_py PUBLIC voltu_sdk) target_link_libraries(voltu_sdk_py PUBLIC voltu_sdk)
set_target_properties(voltu_sdk_py PROPERTIES OUTPUT_NAME voltu) 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 # Python API generator
Dependencies Dependencies
* python3-ply (cpp header parser) * python3-ply (build only)
Build system uses Pybind11 to generate a python module. Most of the bindings are 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 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. ...@@ -34,3 +34,4 @@ build. Several (empty) macros are used in headers to annoate Python API details.
* Static members * Static members
* Constructors * Constructors
* Automatic documentation (Doxygen) * 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: ...@@ -21,6 +21,7 @@ public:
PYBIND11_TYPE_CASTER(voltu::ImageData, _("Image")); PYBIND11_TYPE_CASTER(voltu::ImageData, _("Image"));
bool load(py::handle src, bool convert) { 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"); throw std::runtime_error("ImageData conversion python->c++ not supported");
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment