nestorsalceda / mamba

The definitive testing tool for Python. Born under the banner of Behavior Driven Development (BDD).
http://nestorsalceda.github.io/mamba
MIT License
518 stars 65 forks source link

Should the execution contexts be per-example? #80

Closed angelsanzn closed 6 years ago

angelsanzn commented 8 years ago

Currently, execution contexts are shared among all examples in a group, even among non-sibling examples, so the following fails twice:

with description('top level'):
    with context('first group'):
        with it('an example'):
            self.value = 10

        with it('a second example'):
            expect(self).not_to(have_property('value'))

    with context('second group'):
        with it('another example'):
            expect(self).not_to(have_property('value'))

I believe each example should be given its own execution context. That way, we can enforce a bit more test independence. Having this would mean running all hooks once per example, and I don't see a straightforward way to do it with the current relationship betwen Example and ExampleGroup.

Do you think this behaviour is desirable? Or do you think it's fine to share execution contexts?

nestorsalceda commented 6 years ago

Aye, this is desirable. You should not rely on test order, and thus every example has it own execution context.

In 0.9 series this behaviour si achieved.

Thanks you @angelsanz !

angelsanzn commented 6 years ago

Yeah, nice! 👏