I'm trying to get a behave test done in Python.
A simple behave test per se is no problem. But I'm struggling as soon as I try to use a module from a package I've already created and which is in a parallel directory.
The directory structure is something like:
src
├── connection
│ │
│ └── api_connector.py
│
├── behave_tests
│ │
│ ├─ steps
│ │ │
│ │ └ testCommands.py
│ │
│ ├── testConnection.feature
│ └── testCommands.feature
│
└── unit_tests
Normally, behave is started from inside the behave_tests directory. And at first, it run fine. All Python code for the behave test was in the file testCommands.py, only packages from the python core were used.
But then I changed testCommands.py to use code from my own package connection which is tested and working.
In testCommands.py I wrote the input line
from connection.api_connector import ApiConnector, SerialApiConnector
But this input line isn't resolved by behave, it outputs:
ModuleNotFoundError: No module named 'connection'
I tried to append my package connection to the python module path by adding the following lines to the top of test_commands.py
import sys
sys.path.append('/home/username/projects/projectname/src/connection/')
But it didn't help.
How can I tell behave to use my connection package?