I have a code as follwos in my test_myfunc.py
@pytest.fixture def dummy_string_EN(): return 'This is an English string.' @pytest.fixture def dummy_string_DE(): return 'Das hier ist Deutsch.' @pytest.fixture def dummy_string_FR(): return 'la maison blanche est tombée'
Then I would like to use some of those texts to check my functions:
def test_load_language_models(dummy_string_EN): tee = myfunc(dummy_string_EN) assert tee.language == 'EN' def test_load_language_models(dummy_string_DE): tee = myfunc(dummy_string_DE) assert tee.language == 'DE'
I have around 6 string variables in 4 different languages which are quite long.
It looks to me that I am missing something since it can not be that I can only make the fixture in any other way than returning it from a function.
Is there any other solution to avoid all that boiler plate? i.e. writing the decorator and then defining a method to return a variable?
Source: Python Questions