pytest - combine fixtures into one fixture

Viewed 372

I would like to have three fixtures. They are used to setup configurations for tests, and specify which tests use which configurations.

The three fixtures should be: release_configs dev_configs all_configs

If a test uses the fixture "all_configs", it will be tested for each config session run. If a test uses the fixture "dev_configs", it will be tested only for some subset. If a test uses the fixture "release_configs", it will be tested only for some other subset.

all_configs contains the sum of dev and release.

Is this possible?

Here is what I have for all_configs:

    @pytest.fixture(autouse=False, scope="session", params=release_configs_to_test+dev_configs_to_test, ids=release_configs_to_test+dev_configs_to_test)
    def all_configs(self, request):
        name = request.param
        print('config fixture called')
        self._setup_config(name)
        yield name

Where release_configs_to_test and dev_configs_to_test are just lists of string (name of the config)

EDIT:

Seems like a similar problem to Chaining pytest fixtures which is unsolved.

However, this question is trying to filter fixtures, while I am attempting to combine them.

Either option would be workable, however.

0 Answers
Related