更新时间:2023-02-20 21:26:17
这是一个已知问题: https://github.com/pybuilder/pybuilder/issues/13 .
我最终使用了 pytest-pythonpath .这是我的build.py
的相关部分:
I ended up using pytest-pythonpath. Here is the relevant part of my build.py
:
from pybuilder.core import init, use_plugin
use_plugin("exec")
use_plugin("python.core")
use_plugin("python.unittest")
@init
def initialize(project):
project.set_property("run_unit_tests_command", "py.test %s" % project.expand_path("$dir_source_unittest_python"))
project.set_property("run_unit_tests_propagate_stdout", True)
project.set_property("run_unit_tests_propagate_stderr", True)
这是我的pytest.ini
:
[pytest]
python_paths = src/main/python
现在它可以完美运行:
$ pyb run_unit_tests