Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
lettuce
Commits
f4a00456
Commit
f4a00456
authored
Oct 15, 2010
by
Andres Jaan Tack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added helpers like "step.given(...)" for Given, When and Then.
parent
34d0bdaa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
lettuce/core.py
+9
-0
tests/unit/test_step_runner.py
+54
-0
No files found.
lettuce/core.py
View file @
f4a00456
...
@@ -275,6 +275,15 @@ class Step(object):
...
@@ -275,6 +275,15 @@ class Step(object):
return
matched
,
step_definition
return
matched
,
step_definition
def
given
(
self
,
string
):
return
self
.
behave_as
(
string
)
def
when
(
self
,
string
):
return
self
.
behave_as
(
string
)
def
then
(
self
,
string
):
return
self
.
behave_as
(
string
)
def
behave_as
(
self
,
string
):
def
behave_as
(
self
,
string
):
""" Parses and runs steps given in string form.
""" Parses and runs steps given in string form.
...
...
tests/unit/test_step_runner.py
View file @
f4a00456
...
@@ -301,6 +301,60 @@ def test_count_raised_exceptions_as_failing_steps():
...
@@ -301,6 +301,60 @@ def test_count_raised_exceptions_as_failing_steps():
assert_equals
(
len
(
scenario_result
.
steps_failed
),
1
)
assert_equals
(
len
(
scenario_result
.
steps_failed
),
1
)
finally
:
finally
:
registry
.
clear
()
registry
.
clear
()
def
test_step_runs_subordinate_step_with_given
():
global
simple_thing_ran
simple_thing_ran
=
False
@step
(
'I do something simple'
)
def
simple_thing
(
step
):
global
simple_thing_ran
simple_thing_ran
=
True
@step
(
'I do many complex things'
)
def
complex_things
(
step
):
step
.
given
(
'I do something simple'
)
runnable_step
=
Step
.
from_string
(
'Given I do many complex things'
)
runnable_step
.
run
(
True
)
assert
(
simple_thing_ran
)
del
simple_thing_ran
def
test_step_runs_subordinate_step_with_then
():
global
simple_thing_ran
simple_thing_ran
=
False
@step
(
'I do something simple'
)
def
simple_thing
(
step
):
global
simple_thing_ran
simple_thing_ran
=
True
@step
(
'I do many complex things'
)
def
complex_things
(
step
):
step
.
then
(
'I do something simple'
)
runnable_step
=
Step
.
from_string
(
'Then I do many complex things'
)
runnable_step
.
run
(
True
)
assert
(
simple_thing_ran
)
del
simple_thing_ran
def
test_step_runs_subordinate_step_with_when
():
global
simple_thing_ran
simple_thing_ran
=
False
@step
(
'I do something simple'
)
def
simple_thing
(
step
):
global
simple_thing_ran
simple_thing_ran
=
True
@step
(
'I do many complex things'
)
def
complex_things
(
step
):
step
.
when
(
'I do something simple'
)
runnable_step
=
Step
.
from_string
(
'When I do many complex things'
)
runnable_step
.
run
(
True
)
assert
(
simple_thing_ran
)
del
simple_thing_ran
def
test_multiple_subordinate_steps_are_run
():
def
test_multiple_subordinate_steps_are_run
():
'When a step definition calls two subordinate step definitions (that do not fail), both should run.'
'When a step definition calls two subordinate step definitions (that do not fail), both should run.'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment