Home>

I would like to know if it is possible to set the value of the list of params to fixture when parameterizing the fixture.

All fixtures to put in the list here

def fixture1 (fixture1', fixture2', ...):
  --------
  processing
  --------
  return value

It is a fixture that becomes
The ideal is as follows.

@ pytest.fixture (params = [fixure1, fixture2,<-** I want to put a fixture here !!!! **])
def function (request):
  return request.param

I know I can do it by putting the values ​​in the list normally, but here I want to put the return value of the fixture in the list of params.

  1. When [fixture1, fixture2, ...]

→ It is processed by a function instead of a fixture.

'function' object has no attribute'property'


2. When fixture1 (argument 1, argument 2, ...)
(Note) All arguments are fixture
->I get an error in the argument fixture
Argument 1 is not defined

Corresponding source code
The source code is from the company and cannot be shown. .. .. .. I'm sorry.
All fixtures with arguments 1, 2, ... are in conftest
I would like to describe the fixture and fixture1, fixture2, ... that I want to implement in the test_ ~~~ .py file.
What I tried

I moved the description of conftest to the test_ ~~~ .py file, and tried to write it in @ pytest.mark.parametrize () instead of params = [], but all of them give similar errors. ..

I thought it would be impossible to put the fixture in the value, so I searched, but I couldn't find any article that put the fixture directly in the list value.

Supplementary information (FW/tool version, etc.)

If i have time, thank you.

  • Answer # 1

    Was self resolved.

    https://qiita.com/koreyou/items/c7f756517c974a1a3f02