擅长:python、mysql、java
<p>如果您使用的是Pytest3.0或更高版本,我认为您应该能够通过沿着以下几行编写一个fixture来解决这个特定的场景:</p>
<pre><code>@pytest.fixture(params=['dir1_fixture', 'dir2_fixture'])
def dirname(request):
return request.getfixturevalue(request.param)
</code></pre>
<p>这里的文档:
<a href="http://doc.pytest.org/en/latest/builtin.html#_pytest.fixtures.FixtureRequest.getfixturevalue" rel="noreferrer">http://doc.pytest.org/en/latest/builtin.html#_pytest.fixtures.FixtureRequest.getfixturevalue</a></p>
<p>但是,如果试图动态加载的设备是参数化的,则不能使用此方法。</p>
<p>或者,您可以使用pytest_generate_tests钩子找出一些问题。不过,我还没来得及调查那么多。</p>