Fix code generation steps ordering. closes #85

This commit is contained in:
Anatoly Bubenkov 2014-12-17 22:49:02 +01:00
parent 3e27bd4701
commit c2df5b9873
3 changed files with 15 additions and 6 deletions

View File

@ -1,6 +1,12 @@
Changelog
=========
Unreleased
----------
- Fix code generation steps ordering (bubenkoff)
2.5.1
-----

View File

@ -13,6 +13,7 @@ from .scenario import (
find_argumented_step_fixture_name,
force_encode
)
from .types import STEP_TYPES
PYTHON_REPLACE_REGEX = re.compile("\W")
@ -187,6 +188,7 @@ def group_steps(steps):
if step.name not in seen_steps:
grouped_steps.append(step)
seen_steps.add(step.name)
grouped_steps.sort(key=lambda step: STEP_TYPES.index(step.type))
return grouped_steps
@ -219,7 +221,8 @@ def _show_missing_code_main(config, session):
for step in scenario.steps:
if step.background is None:
steps.remove(step)
print_missing_code(scenarios, steps)
grouped_steps = group_steps(steps)
print_missing_code(scenarios, grouped_steps)
if scenarios or steps:
session.exitstatus = 100

View File

@ -39,13 +39,13 @@ def test_generate(monkeypatch, capsys):
"""I have an empty list."""
@then('my list should be [1]')
def my_list_should_be_1():
"""my list should be [1]."""
@when('I use this fixture')
def i_use_this_fixture():
"""I use this fixture."""
@then('my list should be [1]')
def my_list_should_be_1():
"""my list should be [1]."""
'''[1:].replace(u"'", u"'"))