Open salotz opened 5 years ago
@salotz originally pytest did plan to support "multi" scoped fixture at the declaration level (without the need to to the insane manual name-mangling, however due to a structural issue we chouldn't ship it
Ya my solution ain't the most elegant but from a user's perspective it really isn't that crazy or jarring. I was actually surprised at the paucity of these fixtures. My feeling is that it fits in well with the way that you actually use pytest for most other things, that is having hardcoded behavior from special names.
I think that there should be
tmp_path_factory
s and other similar fixtures with different scopes. I initially started working on this as a PR forpytest-datadir
but the implementation of the scoped factories should really be upstream here. The implementation is simple:https://github.com/gabrielcnr/pytest-datadir/pull/27/files#diff-fb0ca03425023403a38456a8f44597bfR99
The question is whether this is the way to provide them, i.e. the pattern
<scope>_<fixture_name>
e.g.class_tmp_path_factory
.