这是环境
settings.py
from decouple import config
STEMMER = config('STEMMER', default = 'porter')
views.py
from my_project import settings
from nltk import PorterStemmer, LancasterStemmer
if settings.STEMMER == 'porter':
stemmer = PorterStemmer()
elif settings.STEMMER == 'lancaster':
stemmer = LancasterStemmer()
def one_function():
"""Do some stuffs with the stemmer"""
def another_function():
"""Do another stuffs with the stemmer"""
问题是如何使用涵盖两种情况的Pytest
创建测试?
预先感谢
答案 0 :(得分:0)
我将测试拆分。然后,您可以在测试中编辑设置的值,例如:
def test():
settings.STEMMER = "porter"