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
9d8bca20
Commit
9d8bca20
authored
Apr 03, 2010
by
Gabriel Falcão
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
steps aware of its definitions. closes #10
parent
fb94c23d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
lettuce/core.py
+13
-3
tests/unit/test_step_runner.py
+15
-0
No files found.
lettuce/core.py
View file @
9d8bca20
...
@@ -34,6 +34,15 @@ def parse_data_list(lines):
...
@@ -34,6 +34,15 @@ def parse_data_list(lines):
return
keys
,
data_list
return
keys
,
data_list
class
StepDefinition
(
object
):
def
__init__
(
self
,
function
):
self
.
function
=
function
self
.
file
=
function
.
func_code
.
co_filename
self
.
line
=
function
.
func_code
.
co_firstlineno
+
1
def
__call__
(
self
,
*
args
,
**
kw
):
return
self
.
function
(
*
args
,
**
kw
)
class
Step
(
object
):
class
Step
(
object
):
has_definition
=
False
has_definition
=
False
...
@@ -59,17 +68,18 @@ class Step(object):
...
@@ -59,17 +68,18 @@ class Step(object):
if
matched
:
if
matched
:
break
break
return
matched
,
func
return
matched
,
StepDefinition
(
func
)
def
run
(
self
,
ignore_case
):
def
run
(
self
,
ignore_case
):
matched
,
func
=
self
.
_get_match
(
ignore_case
)
matched
,
step_definition
=
self
.
_get_match
(
ignore_case
)
if
not
matched
:
if
not
matched
:
raise
NoDefinitionFound
(
self
)
raise
NoDefinitionFound
(
self
)
else
:
else
:
self
.
has_definition
=
True
self
.
has_definition
=
True
self
.
defined_at
=
step_definition
try
:
try
:
func
()
step_definition
()
except
Exception
,
e
:
except
Exception
,
e
:
self
.
why
=
ReasonToFail
(
e
)
self
.
why
=
ReasonToFail
(
e
)
raise
raise
...
...
tests/unit/test_step_runner.py
View file @
9d8bca20
...
@@ -132,3 +132,18 @@ def test_doesnt_ignore_case():
...
@@ -132,3 +132,18 @@ def test_doesnt_ignore_case():
assert_equals
(
len
(
scenario_result
.
steps_undefined
),
2
)
assert_equals
(
len
(
scenario_result
.
steps_undefined
),
2
)
assert_equals
(
scenario_result
.
total_steps
,
3
)
assert_equals
(
scenario_result
.
total_steps
,
3
)
assert
not
all
([
s
.
has_definition
for
s
in
scenario_result
.
scenario
.
steps
])
assert
not
all
([
s
.
has_definition
for
s
in
scenario_result
.
scenario
.
steps
])
def
test_steps_are_aware_of_its_definitions
():
"Steps are aware of its definitions line numbers and file names"
f
=
Feature
.
from_string
(
FEATURE1
)
feature_result
=
f
.
run
()
scenario_result
=
feature_result
.
scenario_results
[
0
]
for
step
in
scenario_result
.
steps_passed
:
assert
step
.
has_definition
step1
=
scenario_result
.
steps_passed
[
0
]
assert_equals
(
step1
.
defined_at
.
line
,
48
)
assert_equals
(
step1
.
defined_at
.
file
,
__file__
.
rstrip
(
"c"
))
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