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
7a7b86c0
Commit
7a7b86c0
authored
Jan 04, 2013
by
Michael Edwards
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scenario Names now uses Reporter
parent
5b9e49ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
73 deletions
+34
-73
lettuce/plugins/dots.py
+2
-0
lettuce/plugins/reporter.py
+3
-0
lettuce/plugins/scenario_names.py
+21
-67
tests/functional/test_runner.py
+8
-6
No files found.
lettuce/plugins/dots.py
View file @
7a7b86c0
...
...
@@ -18,6 +18,7 @@
import
os
from
lettuce
import
core
from
lettuce.terrain
import
after
from
lettuce.terrain
import
before
from
lettuce.plugins.reporter
import
Reporter
class
DotReporter
(
Reporter
):
...
...
@@ -33,6 +34,7 @@ class DotReporter(Reporter):
reporter
=
DotReporter
()
before
.
each_scenario
(
reporter
.
print_scenario_running
)
after
.
each_scenario
(
reporter
.
print_scenario_ran
)
after
.
each_step
(
reporter
.
store_failed_step
)
after
.
all
(
reporter
.
print_end
)
...
...
lettuce/plugins/reporter.py
View file @
7a7b86c0
...
...
@@ -15,6 +15,9 @@ class Reporter(object):
self
.
scenarios_and_its_fails
[
step
.
scenario
]
=
step
.
why
self
.
failed_scenarios
.
append
(
step
.
scenario
)
def
print_scenario_running
(
self
,
scenario
):
pass
def
print_scenario_ran
(
self
,
scenario
):
pass
...
...
lettuce/plugins/scenario_names.py
View file @
7a7b86c0
...
...
@@ -16,78 +16,32 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
sys
from
lettuce
import
core
from
lettuce.terrain
import
after
from
lettuce.terrain
import
before
from
lettuce.plugins.reporter
import
Reporter
failed_scenarios
=
[]
scenarios_and_its_fails
=
{}
class
NameReporter
(
Reporter
):
def
print_scenario_running
(
self
,
scenario
):
self
.
wrt
(
'
%
s ... '
%
scenario
.
name
)
def
print_scenario_ran
(
self
,
scenario
):
if
scenario
.
passed
:
self
.
wrt
(
"OK"
)
elif
scenario
.
failed
:
reason
=
self
.
scenarios_and_its_fails
[
scenario
]
if
isinstance
(
reason
.
exception
,
AssertionError
):
self
.
wrt
(
"FAILED"
)
else
:
self
.
wrt
(
"ERROR"
)
self
.
wrt
(
"
\n
"
)
def
wrt
(
what
):
if
isinstance
(
what
,
unicode
):
what
=
what
.
encode
(
'utf-8'
)
sys
.
stdout
.
write
(
what
)
reporter
=
NameReporter
()
@before.each_scenario
def
print_scenario_running
(
scenario
):
wrt
(
'
%
s ... '
%
scenario
.
name
)
@after.each_scenario
def
print_scenario_ran
(
scenario
):
if
scenario
.
passed
:
print
"OK"
elif
scenario
.
failed
:
reason
=
scenarios_and_its_fails
[
scenario
]
if
isinstance
(
reason
.
exception
,
AssertionError
):
print
"FAILED"
else
:
print
"ERROR"
@after.each_step
def
save_step_failed
(
step
):
if
step
.
failed
and
step
.
scenario
not
in
failed_scenarios
:
scenarios_and_its_fails
[
step
.
scenario
]
=
step
.
why
failed_scenarios
.
append
(
step
.
scenario
)
@after.all
def
print_end
(
total
):
if
total
.
scenarios_passed
<
total
.
scenarios_ran
:
print
# just a line to separate things here
for
scenario
in
failed_scenarios
:
reason
=
scenarios_and_its_fails
[
scenario
]
wrt
(
str
(
reason
.
step
))
wrt
(
"
\n
"
)
wrt
(
reason
.
traceback
)
wrt
(
"
\n
"
)
word
=
total
.
features_ran
>
1
and
"features"
or
"feature"
wrt
(
"
%
d
%
s (
%
d passed)
\n
"
%
(
total
.
features_ran
,
word
,
total
.
features_passed
))
word
=
total
.
scenarios_ran
>
1
and
"scenarios"
or
"scenario"
wrt
(
"
%
d
%
s (
%
d passed)
\n
"
%
(
total
.
scenarios_ran
,
word
,
total
.
scenarios_passed
))
steps_details
=
[]
for
kind
in
"failed"
,
"skipped"
,
"undefined"
:
attr
=
'steps_
%
s'
%
kind
stotal
=
getattr
(
total
,
attr
)
if
stotal
:
steps_details
.
append
(
"
%
d
%
s"
%
(
stotal
,
kind
))
steps_details
.
append
(
"
%
d passed"
%
total
.
steps_passed
)
word
=
total
.
steps
>
1
and
"steps"
or
"step"
wrt
(
"
%
d
%
s (
%
s)
\n
"
%
(
total
.
steps
,
word
,
", "
.
join
(
steps_details
)))
before
.
each_scenario
(
reporter
.
print_scenario_running
)
after
.
each_scenario
(
reporter
.
print_scenario_ran
)
after
.
each_step
(
reporter
.
store_failed_step
)
after
.
all
(
reporter
.
print_end
)
def
print_no_features_found
(
where
):
...
...
@@ -95,5 +49,5 @@ def print_no_features_found(where):
if
not
where
.
startswith
(
os
.
sep
):
where
=
'.
%
s
%
s'
%
(
os
.
sep
,
where
)
wrt
(
'Oops!
\n
'
)
wrt
(
'could not find features at
%
s
\n
'
%
where
)
reporter
.
wrt
(
'Oops!
\n
'
)
reporter
.
wrt
(
'could not find features at
%
s
\n
'
%
where
)
tests/functional/test_runner.py
View file @
7a7b86c0
...
...
@@ -908,6 +908,7 @@ def test_output_level_2_fail():
assert_stdout_lines_with_traceback
(
"See it fail ... FAILED
\n
"
"
\n
"
"
\n
"
"<Step:
\"
And this one fails
\"
>
\n
"
"Traceback (most recent call last):
\n
"
' File "
%(lettuce_core_file)
s", line
%(call_line)
d, in __call__
\n
'
...
...
@@ -937,6 +938,7 @@ def test_output_level_2_error():
"It should pass ... OK
\n
"
"It should raise an exception different of AssertionError ... ERROR
\n
"
"
\n
"
"
\n
"
"<Step:
\"
Given my step that blows a exception
\"
>
\n
"
"Traceback (most recent call last):
\n
"
' File "
%(lettuce_core_file)
s", line
%(call_line)
d, in __call__
\n
'
...
...
@@ -1233,10 +1235,10 @@ def test_output_background_with_success_colorless():
' I want to automate its test # tests/functional/bg_features/simple/simple.feature:4
\n
'
'
\n
'
' Background:
\n
'
' Given the variable "X" holds 2 # tests/functional/test_runner.py:12
19
\n
'
' Given the variable "X" holds 2 # tests/functional/test_runner.py:12
21
\n
'
'
\n
'
' Scenario: multiplication changing the value # tests/functional/bg_features/simple/simple.feature:9
\n
'
' Given the variable "X" is equal to 2 # tests/functional/test_runner.py:12
19
\n
'
' Given the variable "X" is equal to 2 # tests/functional/test_runner.py:12
21
\n
'
'
\n
'
'1 feature (1 passed)
\n
'
'1 scenario (1 passed)
\n
'
...
...
@@ -1268,12 +1270,12 @@ def test_output_background_with_success_colorful():
'
\033
[1;37m I want to automate its test
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:4
\033
[0m
\n
'
'
\n
'
'
\033
[1;37m Background:
\033
[0m
\n
'
'
\033
[1;30m Given the variable "X" holds 2
\033
[1;30m# tests/functional/test_runner.py:125
4
\033
[0m
\n
'
'
\033
[A
\033
[1;32m Given the variable "X" holds 2
\033
[1;30m# tests/functional/test_runner.py:125
4
\033
[0m
\n
'
'
\033
[1;30m Given the variable "X" holds 2
\033
[1;30m# tests/functional/test_runner.py:125
6
\033
[0m
\n
'
'
\033
[A
\033
[1;32m Given the variable "X" holds 2
\033
[1;30m# tests/functional/test_runner.py:125
6
\033
[0m
\n
'
'
\n
'
'
\033
[1;37m Scenario: multiplication changing the value
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:9
\033
[0m
\n
'
'
\033
[1;30m Given the variable "X" is equal to 2
\033
[1;30m# tests/functional/test_runner.py:125
4
\033
[0m
\n
'
'
\033
[A
\033
[1;32m Given the variable "X" is equal to 2
\033
[1;30m# tests/functional/test_runner.py:125
4
\033
[0m
\n
'
'
\033
[1;30m Given the variable "X" is equal to 2
\033
[1;30m# tests/functional/test_runner.py:125
6
\033
[0m
\n
'
'
\033
[A
\033
[1;32m Given the variable "X" is equal to 2
\033
[1;30m# tests/functional/test_runner.py:125
6
\033
[0m
\n
'
'
\n
'
'
\033
[1;37m1 feature (
\033
[1;32m1 passed
\033
[1;37m)
\033
[0m
\n
'
'
\033
[1;37m1 scenario (
\033
[1;32m1 passed
\033
[1;37m)
\033
[0m
\n
'
...
...
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