【发布时间】:2016-09-01 12:32:58
【问题描述】:
所以我有一个使用 boost::python (C++) 创建的共享库。
对于里面的 C++ 函数,我有单元测试来检查它们是否正常工作。
现在我想使用单元测试来查看我是否正确实现了python接口。
为此我考虑过使用python包unittest。
现在我的文件夹设置大致如下:
project
|
-- C++ source (library and boost::python stuff)
|
-- build (here the shared library is located)
|
-- Test (here I have the python classes that should test the interface)
test 文件夹有一些反映 python 接口结构的子文件夹,包含许多用于测试库不同方面的小型 python 模块。
现在问题:
我如何
import共享库进入测试?
到目前为止,我尝试的是在我的test_main.py
import sys
sys.path.insert(0,'../build')
但这对 test 文件夹中的模块没有帮助。无论如何,将这条路径硬编码到测试代码中似乎是 hackish。我也不想安装未经测试的库只是为了找出测试失败然后再次卸载它。
【问题讨论】:
标签: python c++ unit-testing boost out-of-source