是否可以覆盖pytest装置的范围?

ajw*_*ood 10 python scope fixtures pytest

pytest的内置灯具的范围可以改变吗?

这不起作用:

@pytest.fixture(scope="class")
def myFixture(tmpdir):
    pass
Run Code Online (Sandbox Code Playgroud)

...因为tmpdir功能范围:

ScopeMismatch: You tried to access the 'function' scoped fixture 'tmpdir' with a 'class' scoped request object, involved factories
Run Code Online (Sandbox Code Playgroud)

是否有可能覆盖pytest的内置灯具的范围,这样我就可以得到一个类范围的tmpdir灯具?

Ron*_*nny 5

那不可能,

下一个版本将包括一个名为 tmpdir_factory 的会话范围夹具

并且还计划了一个“任何”范围,该范围将为每个范围设置一次夹具