Pytest command line argument for all new run configurations in PyCharm
I am working on a project (pymeasure) where we run pytest tests were you need to assign a fixture through the command line arguments:
python -m pytest path/to/file --device-address="[address]"
This is needed for any and all tests.
Fortunately there is the `Additional Arguments` option in a run configuration where I can add this flag.
Unfortunately, I need to this again for every possible configuration. I might set up the run config for the whole file, but if I ran any of the many individual tests, the CLI argument is not inherited. So for every single test I have to click "Edit configuration..." and add in the argument before running.
Not to mention when the address changes and I have to modify dozens of configs again.
Is there an option to let these Additional Arguments inherit in a file? Or create some sort of default?
Unrelated to PyCharm, is there an option in pytest to maybe get the argument from the environment or something?
Thanks!
Please sign in to leave a comment.
Run/debug configuration templates should cover this case -- https://www.jetbrains.com/help/pycharm/run-debug-configuration.html#change-template
Ah, that works.
Is that stored per project or for all projects?
One downside of using the template is I cannot modify existing configurations. However, when the device address changes I can just remove all existing configs, modify the template and click 'run' for anything.