Pybuilder And Pytest: Cannot Import Source Code When Running Tests
so i have a project: |- src |-main |-python |-data_merger |- common |- constans |- controller
Solution 1:
This is a known issue: https://github.com/pybuilder/pybuilder/issues/13.
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")
@initdefinitialize(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)
And here is my pytest.ini
:
[pytest]python_paths = src/main/python
And now it works perfectly:
$ pyb run_unit_tests
Post a Comment for "Pybuilder And Pytest: Cannot Import Source Code When Running Tests"