Consider the following pseudocode demonstrating my question:
import pytest
@pytest.fixture
def param1():
# return smth
yield "wilma"
@pytest.fixture
def param2():
# return smth
yield "fred"
@pytest.fixture
def bar(param1, param2):
#do smth
return [Bar(param1, param2), Bar(param1, param2)]
@pytest.fixture
def first_bar(bar):
return bar[0]
class Test_first_bar:
# FIXME: how do I do that?
#def setup_smth???(self, first_bar):
# self.bar = first_bar
def test_first_bar_has_wilma(self):
# some meaningful check number 1
assert self.bar.wilma == "wilma"
def test_first_bar_some_other_check(self):
# some meaningful check number 2
assert self.bar.fred == "fred"
Basically I want to pass first_bar
fixture to my Test_first_bar
class in order to reuse that object in all its test methods. How should I go about dealing with such situation?
Python 3, if that matters.