i'm handling a very big test suite,
that needs references to a lot of assets, usernames, password, endpoints, and so on.
now,
all the configuration is stored inside a configuration.py module, imported from the test files.
when i need to change environment (e.g. from quality to production) i rename the configuration.py file using the right one.
Obviously this is not a good approach to configuration, but I'm having difficulties choosing the right approach.
my actual approach is to store configuration in a external json file and choose the file with a command line parameter, using pytest_addoption hook in conftest.py in order to get the configuration json as a dict in a fixture.
this approach has some problems probably because I don't know how to use pytest properly, so I apologize and ask for some advice :
so i think i keep storing configuration in a configuration.py modules changing the configuration.py file with a script, in this way :
even i was searching for a more cute way to load configuration.
thanks for your time.
i have a similar situation at a work project, we have a set of project local pytest plugins that facilitate providing the loaded configuration from convention based locations as well as taking cli options to puck the variant/environment for each test
those "local" pytest plugins get activated using a entrypoint and a lot of pytest_plugins declarations in other plugins (we don't just handle configuration loading but also markers, contextual parametrization, end2end environment selection and a few other details)
@RonnyPfannschmidt thanks for your suggestion. i will take a look at the plugin. i also tried this plugin https://github.com/wojole/pytest-testconfig but i think conftest runs before the plugin so if you need configuration in conftest you cannot use it (https://github.com/wojole/pytest-testconfig/issues/8)
@andreabisello declaring a own plugin using a entrypoint means its running before conftest
Closing this issue as I think the question has been answered.
yes, thanks.