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

`before.all` executed again for all nested example groups. #91

Open PhilHarnish opened 6 years ago

PhilHarnish commented 6 years ago

before.all seems to be executed for each example group (good) and again for all inner groups (bad?). Perhaps this is even WAI and the "fix" is more clarification in the docs?

This behavior started once I updated:

$ mamba --version
0.8.6
# ^ This version was OK.
$ pip install mamba -U
Collecting mamba
  Downloading mamba-0.9.2.tar.gz
# (...snip...)

Here's a sample test:

from spec.mamba import *

times_called = 0

with description('has before all'):
  with before.all:
    global times_called
    print('Running before.all')
    times_called += 1

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

  with description('inner description'):
    with it('should have run before.all once'):
      expect(times_called).to(equal(1))  # Fails; times_called == 2.

  with context('inner context'):
    with it('should have run before.all once'):
      expect(times_called).to(equal(1))  # Fails; times_called == 3.
nestorsalceda commented 6 years ago

Aye, this is my fault!

Going to fix it!

Thanks for reporting @PhilHarnish !

nestorsalceda commented 6 years ago

It's fixed now!

I'm going to prepare a release for next week for closing this issue.

Thanks!