There are some variables defined in the test methods whose value I want to use in the setup fixture I have created, to elaborate it more, following is the problem:
@pytest.fixture
def fixture_method():
....
....
**print(variable_from_test_method)**
....
....
def test_case():
variable_from_test_method = 'This is my variable's value which I want to pass to fixture'
What I want to achieve is that I want to use the variable named 'variable_from_test_method ' defined in my test method named 'test_case' into my fixure named 'fixture_method'.
I was searching for some solution by using 'request' object but unable to understand how I can bring it into use.
You can't, the
fixture
runs before the test. You can define it in thefixture
and pass it to the test usingreturn