我们成功地使用pytest(Python3)来运行测试套件来测试一些硬件设备(电子设备)。对于这些测试的一个子集,我们需要测试人员更改硬件布置,然后再将其改回。我的方法是使用附加到相关测试的模块级固定装置(它们都在一个单独的模块中),带有两个input调用:@pytest.fixture(scope="module")defdisconnect_component():input('Disconnectcomponent,thenpressenter')yield#Atthispointallthetestswiththisfixtureareruninput('Connectcomp