Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before.all/after.all should only run once when using nested hooks #105

Open
razorx89 opened this issue Mar 11, 2018 · 2 comments
Open

before.all/after.all should only run once when using nested hooks #105

razorx89 opened this issue Mar 11, 2018 · 2 comments

Comments

@razorx89
Copy link

When using nested hooks, mamba executes the whole stack of hooks instead of only the hooks in the current scope. See the MWE for more details. This problem is also present with the after.all hook.

spec.py:

from mamba import before, description, it
from expects import *


num_outer_called = 0
num_inner_called = 0


with description('Bug'):
    with before.all:
        global num_outer_called
        num_outer_called += 1
        print('outer.before.all')

    with it('should have run before.all once'):
        expect(num_outer_called).to(equal(1))

    with description('when having a nested before.all'):
        with before.all:
            global num_inner_called
            num_inner_called += 1
            print('inner.before.all')

        with it('should have run the inner before.all once'):
            expect(num_inner_called).to(equal(1))

        with it('should have still run the outer before.all only once'):
            expect(num_outer_called).to(equal(1))  # Failed with 'expected: 2 to equal 1'
@nestorsalceda
Copy link
Owner

Hey @razorx89

Is this happening with latest release?

I think this was fixed in 65100b5 and d4d0744 but perhaps I missed some detail.

Thanks!

@ksaifullah
Copy link

Experiencing this problem. . .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants