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!

1
3 comments

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.

0
You can choose where to store the templates. By default, they are stored in IDE config, but you can enable a checkbox to store them as project files.
0

Please sign in to leave a comment.