Commit 2f7d20b0 by Gabriel Falcao

Only calling @before.all if there are features. closes #315

parent b44e11b0
...@@ -133,8 +133,6 @@ class Runner(object): ...@@ -133,8 +133,6 @@ class Runner(object):
print "Error loading step definitions:\n", e print "Error loading step definitions:\n", e
return return
call_hook('before', 'all')
results = [] results = []
if self.single_feature: if self.single_feature:
features_files = [self.single_feature] features_files = [self.single_feature]
...@@ -147,6 +145,8 @@ class Runner(object): ...@@ -147,6 +145,8 @@ class Runner(object):
self.output.print_no_features_found(self.loader.base_dir) self.output.print_no_features_found(self.loader.base_dir)
return return
call_hook('before', 'all')
failed = False failed = False
try: try:
for filename in features_files: for filename in features_files:
......
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import commands import commands
from lettuce.fs import FileSystem from lettuce.fs import FileSystem
from sure import expect
current_directory = FileSystem.dirname(__file__) current_directory = FileSystem.dirname(__file__)
def test_django_agains_couves(): def test_django_agains_couves():
'it always call @after.all hooks, even after exceptions' 'it always call @after.all hooks, even after exceptions'
...@@ -26,7 +28,18 @@ def test_django_agains_couves(): ...@@ -26,7 +28,18 @@ def test_django_agains_couves():
status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3") status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3")
assert "Couves before all" in out expect("Couves before all").to.be.within(out)
assert "Couves after all" in out expect("Couves after all").to.be.within(out)
FileSystem.popd() FileSystem.popd()
def test_django_agains_couves_nohooks():
'it only calls @before.all and @after.all hooks if there are features found'
FileSystem.pushd(current_directory, "django", "couves")
status, out = commands.getstatusoutput("python manage.py harvest --verbosity=3 --tags=nothingwillbefound")
expect("Couves before all").to.not_be.within(out)
expect("Couves after all").to.not_be.within(out)
FileSystem.popd()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment