[pytest-dev] solving the "too static" fixture scope problem

Florian Schulze florian.schulze at gmx.net
Fri Oct 11 13:09:26 CEST 2013


On 11.10.2013, at 12:57, holger krekel <holger at merlinux.eu> wrote:

> On Fri, Oct 11, 2013 at 12:51 +0200, Florian Schulze wrote:
>> I would expect the behaviour you describe for scope="each" to be the default for a fixture without a scope. Why introduce a new scope for that? Am I missing something? I haven't used pytest for such complex things yet.
> 
> Defaulting to scope="each" is an interesting proposition but it
> would be largely backward-compatible and i think in real situations. 
> Consider a fixture like this:
> 
>    @pytest.fixture
>    def db(...):
>        return DbInstance()
> 
> and then a test and other fixtures using this "db" fixture.  They
> would all get distinct instances (people using fixtures more extensively
> implicitly rely on the current per-test "sharing" of resources and i think
> it makes sense, just not for all resources).

Ah, I think I get the difference now.

Regards,
Florian Schulze



More information about the Pytest-dev mailing list