Debugging with pytest in an IDE such as pycharm or vs code #939
Replies: 1 comment
-
I have no experience with IDEs, but since nobody else stepped up, I'll try to answer this anyways.
The environment fixture needs to know on which configuration to work. That's why you need to supply that.
You can supply all needed configurations to pytest via environment variables:
|
Beta Was this translation helpful? Give feedback.
-
Hi labgrid'ers,
I was wondering if anybody has had success with setting up an IDE for running and debugging tests using pytest from within an IDE such as PyCharm or Visual Studio code?
I am having a bit of difficulties setting it up.
I use a target yaml file for fixture configuration:
Using pytest -lg-env I can apply the fixture configuration to a test, just as stated in the beginning of the labgrid documentation.
Enter an IDE to be able to have an integrated debugging session. Yes, that would be nice. Take PyCharm or Visual Studio Code - those are the ones I have tried - If you know any solution, even to another IDE, please do not hestitate to reply.
It seems, the --lg-env parameter is difficult to pass correctly, thus leaving the test without a fixture environment, which inevitably fails.
I have tried passing it through the Pycharm run options parameter, but then pytest cannot find the target file.
"ERROR: not found: .... no name in any module..." - or so, to that effect.
I have tried passing it through the VS Code pytestargs paramter in the settings.json.
I have also tried in both environments to use lg-env=LG-ENV to direct to the pytest.ini file to limited success.
I do not know how this should be set up exactly, and what should be put i the pytest.ini file for it to set the target environment file,
Can you help?
Beta Was this translation helpful? Give feedback.
All reactions