Skip to content

Commit

Permalink
Merge pull request #97 from jes5e/always_after_each
Browse files Browse the repository at this point in the history
Fixes issue #96 - after.each only executes if examples pass.
  • Loading branch information
nestorsalceda authored Jan 9, 2018
2 parents 59091a9 + 526d2cb commit 1e805b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
build
dist
.coverage
.idea
3 changes: 1 addition & 2 deletions mamba/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def execute(self, reporter, execution_context, tags=None):
if self.error is None:
self._execute_test(execution_context)

if self.error is None:
self.parent.execute_hook('after_each', execution_context)
self.parent.execute_hook('after_each', execution_context)

self.was_run = True
self._finish(reporter)
Expand Down
6 changes: 3 additions & 3 deletions spec/errors_in_hooks_spec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mamba import description, before, it, context
from expects import expect, be_none, be_a, be_true
from expects import expect, be_none, be_a, be_true, be_false
from doublex import Spy

from mamba import reporter, runnable
Expand Down Expand Up @@ -75,13 +75,13 @@
expect(self.example.error).not_to(be_none)

with context('when an error happened in the example'):
with it('does not execute after_each hook'):
with it('still executes after_each hook'):
self.example = a_failing_example()
self.example_group.append(self.example)

self.example_group.execute(self.reporter, runnable.ExecutionContext())

expect(isinstance(self.example.error.exception, ValueError)).to(be_true)
expect(isinstance(self.example.error.exception, ValueError)).to(be_false)

with context('when an error was raised in an after.all hook'):
with before.each:
Expand Down

0 comments on commit 1e805b6

Please sign in to comment.