how to avoid boiler plate with a simple fixture in pytest

  fixtures, pytest, python

I have a code as follwos in my

def dummy_string_EN():
    return 'This is an English string.'

def dummy_string_DE():
    return 'Das hier ist Deutsch.'

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