我想创建一个带有单元测试和包的 pybuilder 项目。例如,修改了简单的 python 应用程序示例,将“helloworld”移动到包“hello”。
我的第一直觉是将包结构与“main”和“unittest”源相匹配:
+---src
+---main
| \---python
| \---hello
| helloworld.py
| __init__.py
|
\---unittest
\---python
\---hello
helloworld_tests.py
__init__.py
由于“hello”包冲突,这不起作用。
BUILD FAILED - 'module' object has no attribute 'helloworld_tests'
我看到pybuilder本身只是跳过了单元测试中的顶级 pybuilder 包,但如果有多个顶级包则不会这样做。
我的第二个猜测是为单元测试创建额外的顶级包。
\---unittest
\---python
\---tests
| __init__.py
\---hello
helloworld_tests.py
__init__.py
是否有更好的解决方案或既定惯例如何在包中组织 python 测试?