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
040938ae
Commit
040938ae
authored
Oct 20, 2012
by
Gabriel Falcao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementing the colored output of backgrounds
parent
6c331b29
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
68 deletions
+76
-68
lettuce/core.py
+1
-0
lettuce/plugins/colored_shell_output.py
+10
-2
lettuce/registry.py
+1
-1
tests/asserts.py
+1
-1
tests/functional/test_runner.py
+63
-64
No files found.
lettuce/core.py
View file @
040938ae
...
@@ -867,6 +867,7 @@ class Background(object):
...
@@ -867,6 +867,7 @@ class Background(object):
results
=
[]
results
=
[]
for
step
in
self
.
steps
:
for
step
in
self
.
steps
:
matched
,
step_definition
=
step
.
pre_run
(
ignore_case
)
call_hook
(
'before_each'
,
'step'
,
step
)
call_hook
(
'before_each'
,
'step'
,
step
)
try
:
try
:
results
.
append
(
step
.
run
(
ignore_case
))
results
.
append
(
step
.
run
(
ignore_case
))
...
...
lettuce/plugins/colored_shell_output.py
View file @
040938ae
...
@@ -62,7 +62,7 @@ def print_step_running(step):
...
@@ -62,7 +62,7 @@ def print_step_running(step):
color
=
'
\033
[1;30m'
color
=
'
\033
[1;30m'
if
step
.
scenario
.
outlines
:
if
step
.
scenario
and
step
.
scenario
.
outlines
:
color
=
'
\033
[0;36m'
color
=
'
\033
[0;36m'
string
=
step
.
represent_string
(
step
.
original_sentence
)
string
=
step
.
represent_string
(
step
.
original_sentence
)
...
@@ -75,7 +75,7 @@ def print_step_running(step):
...
@@ -75,7 +75,7 @@ def print_step_running(step):
@after.each_step
@after.each_step
def
print_step_ran
(
step
):
def
print_step_ran
(
step
):
if
step
.
scenario
.
outlines
:
if
step
.
scenario
and
step
.
scenario
.
outlines
:
return
return
if
step
.
hashes
and
step
.
defined_at
:
if
step
.
hashes
and
step
.
defined_at
:
...
@@ -250,3 +250,11 @@ def print_no_features_found(where):
...
@@ -250,3 +250,11 @@ def print_no_features_found(where):
write_out
(
write_out
(
'
\033
[1;37mcould not find features at '
'
\033
[1;37mcould not find features at '
'
\033
[1;33m
%
s
\033
[0m
\n
'
%
where
)
'
\033
[1;33m
%
s
\033
[0m
\n
'
%
where
)
@before.each_background
def
print_background_running
(
background
):
wrt
(
'
\n
'
)
wrt
(
'
\033
[1;37m'
)
wrt
(
background
.
represented
())
wrt
(
'
\033
[0m
\n
'
)
lettuce/registry.py
View file @
040938ae
...
@@ -90,7 +90,7 @@ def call_hook(situation, kind, *args, **kw):
...
@@ -90,7 +90,7 @@ def call_hook(situation, kind, *args, **kw):
print
"="
*
1000
print
"="
*
1000
traceback
.
print_exc
(
e
)
traceback
.
print_exc
(
e
)
print
print
raise
SystemExit
(
2
)
raise
def
clear
():
def
clear
():
...
...
tests/asserts.py
View file @
040938ae
...
@@ -60,7 +60,7 @@ def assert_lines_unicode(original, expected):
...
@@ -60,7 +60,7 @@ def assert_lines_unicode(original, expected):
msg
=
(
u'Output differed as follows:
\n
{0}
\n
'
msg
=
(
u'Output differed as follows:
\n
{0}
\n
'
'Output was:
\n
{1}
\n
Expected was:
\n
{2}'
.
encode
(
'utf-8'
))
'Output was:
\n
{1}
\n
Expected was:
\n
{2}'
.
encode
(
'utf-8'
))
raise
AssertionError
(
msg
.
format
(
diff
,
original
,
expected
))
raise
AssertionError
(
repr
(
msg
.
format
(
diff
,
original
,
expected
))
.
replace
(
r'\n'
,
'
\n
'
))
assert_equals
(
assert_equals
(
len
(
expected
),
len
(
original
),
len
(
expected
),
len
(
original
),
...
...
tests/functional/test_runner.py
View file @
040938ae
...
@@ -695,35 +695,6 @@ def test_output_with_failful_outline_colorful():
...
@@ -695,35 +695,6 @@ def test_output_with_failful_outline_colorful():
)
)
@with_setup
(
prepare_stderr
)
def
test_many_features_a_file
():
"syntax checking: Fail if a file has more than one feature"
filename
=
syntax_feature_name
(
'many_features_a_file'
)
runner
=
Runner
(
filename
)
assert_raises
(
SystemExit
,
runner
.
run
)
assert_stderr_lines
(
'Syntax error at:
%
s
\n
'
'A feature file must contain ONLY ONE feature!
\n
'
%
filename
)
@with_setup
(
prepare_stderr
)
def
test_feature_without_name
():
"syntax checking: Fail on features without name"
filename
=
syntax_feature_name
(
'feature_without_name'
)
runner
=
Runner
(
filename
)
assert_raises
(
SystemExit
,
runner
.
run
)
assert_stderr_lines
(
'Syntax error at:
%
s
\n
'
'Features must have a name. e.g: "Feature: This is my name"
\n
'
%
filename
)
@with_setup
(
prepare_stdout
)
@with_setup
(
prepare_stdout
)
def
test_output_snippets_with_groups_within_double_quotes_colorless
():
def
test_output_snippets_with_groups_within_double_quotes_colorless
():
"Testing that the proposed snippet is clever enough to identify groups within double quotes. colorless"
"Testing that the proposed snippet is clever enough to identify groups within double quotes. colorless"
...
@@ -1258,10 +1229,10 @@ def test_output_background_with_success_colorless():
...
@@ -1258,10 +1229,10 @@ def test_output_background_with_success_colorless():
' I want to automate its test # tests/functional/bg_features/simple/simple.feature:4
\n
'
' I want to automate its test # tests/functional/bg_features/simple/simple.feature:4
\n
'
'
\n
'
'
\n
'
' Background:
\n
'
' Background:
\n
'
' Given the variable "X" holds 2 # tests/functional/test_runner.py:12
44
\n
'
' Given the variable "X" holds 2 # tests/functional/test_runner.py:12
15
\n
'
'
\n
'
'
\n
'
' Scenario: multiplication changing the value # tests/functional/bg_features/simple/simple.feature:9
\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
44
\n
'
' Given the variable "X" is equal to 2 # tests/functional/test_runner.py:12
15
\n
'
'
\n
'
'
\n
'
'1 feature (1 passed)
\n
'
'1 feature (1 passed)
\n
'
'1 scenario (1 passed)
\n
'
'1 scenario (1 passed)
\n
'
...
@@ -1269,36 +1240,64 @@ def test_output_background_with_success_colorless():
...
@@ -1269,36 +1240,64 @@ def test_output_background_with_success_colorless():
)
)
# @with_setup(prepare_stdout)
@with_setup
(
prepare_stdout
)
# def test_output_background_with_success_colorful():
def
test_output_background_with_success_colorful
():
# "A feature with background should print it accordingly under verbosity 4"
"A feature with background should print it accordingly under verbosity 4"
# from lettuce import step
from
lettuce
import
step
# @step(ur'the variable "(\w+)" holds (\d+)')
@step
(
ur'the variable "(\w+)" holds (\d+)'
)
# @step(ur'the variable "(\w+)" is equal to (\d+)')
@step
(
ur'the variable "(\w+)" is equal to (\d+)'
)
# def just_pass(step, *args):
def
just_pass
(
step
,
*
args
):
# pass
pass
# filename = bg_feature_name('simple')
filename
=
bg_feature_name
(
'simple'
)
# runner = Runner(filename, verbosity=4)
runner
=
Runner
(
filename
,
verbosity
=
4
)
# runner.run()
runner
.
run
()
# assert_stdout_lines(
assert_stdout_lines
(
# '\n'
'
\n
'
# 'Feature: Simple and successful # tests/functional/bg_features/simple/simple.feature:1\n'
'
\033
[1;37mFeature: Simple and successful
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:1
\033
[0m
\n
'
# ' As the Lettuce maintainer # tests/functional/bg_features/simple/simple.feature:2\n'
'
\033
[1;37m As the Lettuce maintainer
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:2
\033
[0m
\n
'
# ' In order to make sure the output is pretty # tests/functional/bg_features/simple/simple.feature:3\n'
'
\033
[1;37m In order to make sure the output is pretty
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:3
\033
[0m
\n
'
# ' I want to automate its test # tests/functional/bg_features/simple/simple.feature:4\n'
'
\033
[1;37m I want to automate its test
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:4
\033
[0m
\n
'
# '\n'
'
\n
'
# ' Background:\n'
'
\033
[1;37m Background:
\033
[0m
\n
'
# ' Given the variable "X" holds 2 # tests/functional/test_runner.py:1244\n'
'
\033
[1;30m Given the variable "X" holds 2
\033
[1;30m# tests/functional/test_runner.py:1250
\033
[0m
\n
'
# '\n'
'
\033
[A
\033
[1;32m Given the variable "X" holds 2
\033
[1;30m# tests/functional/test_runner.py:1250
\033
[0m
\n
'
# ' Scenario: multiplication changing the value # tests/functional/bg_features/simple/simple.feature:9\n'
'
\n
'
# ' Given the variable "X" is equal to 2 # tests/functional/test_runner.py:1244\n'
'
\033
[1;37m Scenario: multiplication changing the value
\033
[1;30m# tests/functional/bg_features/simple/simple.feature:9
\033
[0m
\n
'
# '\n'
'
\033
[1;30m Given the variable "X" is equal to 2
\033
[1;30m# tests/functional/test_runner.py:1250
\033
[0m
\n
'
# '1 feature (1 passed)\n'
'
\033
[A
\033
[1;32m Given the variable "X" is equal to 2
\033
[1;30m# tests/functional/test_runner.py:1250
\033
[0m
\n
'
# '1 scenario (1 passed)\n'
'
\n
'
# '1 step (1 passed)\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
'
'
\033
[1;37m1 step (
\033
[1;32m1 passed
\033
[1;37m)
\033
[0m
\n
'
)
@with_setup
(
prepare_stderr
)
def
test_many_features_a_file
():
"syntax checking: Fail if a file has more than one feature"
filename
=
syntax_feature_name
(
'many_features_a_file'
)
runner
=
Runner
(
filename
)
expect
(
runner
.
run
)
.
to
.
throw
(
SystemExit
,
(
'Syntax error at:
%
s
\n
'
'A feature file must contain ONLY ONE feature!
\n
'
%
filename
))
@with_setup
(
prepare_stderr
)
def
test_feature_without_name
():
"syntax checking: Fail on features without name"
filename
=
syntax_feature_name
(
'feature_without_name'
)
runner
=
Runner
(
filename
)
expect
(
runner
.
run
)
.
to
.
throw
(
SystemExit
,
(
'Syntax error at:
%
s
\n
'
'Features must have a name. e.g: "Feature: This is my name"
\n
'
%
filename
))
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