What would be the recommended way to deal with this situation in pytest 4? Are we encouraged to copy-paste code from fixtures we want to override, or is there another way to "inherit" a fixture, and inject e.g custom behavior before as well as after it is called?推荐答案要在调用初始夹具之前注入自定义行为,您可以创建具有此行为的单独夹具,并在夹具参数列表中的初始夹具之前使用它来替代之前覆盖的夹具.定义:To inject custom behavior before the initial fixture is called you can create separate fixture with this behavior and use it before the initial fixture in parameter list of fixture that overrides previously defined:@pytest.fixture(scope='session')def inject_before(): print('inject_before')@pytest.fixture(scope='session')def django_db_setup(inject_before, django_db_setup): print('inject_after') 这篇关于如何重写在pytest 4中调用原始的pytest固定装置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-08 23:52