Open hamish-miller opened 5 years ago
Only skimmed the issue, but sounds like idfnset
(to generate IDs for the complete set, given index, argvalues, item as arguments) might help? (ref https://github.com/blueyed/pytest/pull/104, after https://github.com/pytest-dev/pytest/pull/6174).
Thanks for the quick response.
generating IDs for the complete set
sounds like what I'm trying to achieve.
I'll have a look at your PRs to verify.
pip list
from the virtual environment you are usingDescription
Brief
I am trying to provide
pytest
aidfn
after it has generated a large combinatorial dataset via modular parametrized fixtures.Context
pytest.mark.parametrize
is really useful for quickly generating multiple sets of data for a particular test. It's particularly great when stacked to generate all combinations of multiple parametrized arguments.pytest
provides a mechanism for automatically generating a test id from the params based on whether the param is primitive/non-primitive. It also allows the user to provide anidfn
so that the test input can be expressed in a way more relevant to the problem domain.@pytest.fixture
is allowed to be parametrized viaparams
. It is also modular and can use other fixtures, which in turn can be parametrized, but it need not be aware of that.Using the above 3 properties of
pytest
, I am able to pass in a single fixture to a test function that uses two other parametrized fixtures, and converts their raw values into anamedtuple
that better reflects the problem domain.However, I am more interested in the composite data produced by the single fixture than the primitive data it acquires from the other fixtures, and would like to reflect this in the output of
pytest
.I have tried:
idfn
to@pytest.fixture(ids=
idfn
to@pytest.mark.parametrize(..., ids=
pytest_make_parametrize_id
inconftest.py
all without success.
pip list
versions
Example
Output
Desired Output
Quickfix
For this small scenario it's possible to write something along the lines:
Which will achieve the desired output, but at the cost of easily extending the tests.
Flaws in the regex could quickly be found with test params:
c_define.name = "foo_bar"
c_define.value = "0xF"
c_define.string = "#define{space}{space}foo{space}{space}1"
And it would be much easier to append these instances to a
pytest.mark.parametrize
list.