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
41ceafa8
Commit
41ceafa8
authored
Apr 24, 2010
by
Gabriel Falcão
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling no features found
parent
4bc52d86
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
9 deletions
+136
-9
lettuce/__init__.py
+17
-7
lettuce/plugins/colored_shell_output.py
+12
-0
lettuce/plugins/non_verbose.py
+77
-0
lettuce/plugins/shell_output.py
+13
-0
lettuce/script.py
+3
-1
tests/functional/test_runner.py
+14
-1
No files found.
lettuce/__init__.py
View file @
41ceafa8
...
@@ -63,25 +63,35 @@ class Runner(object):
...
@@ -63,25 +63,35 @@ class Runner(object):
sys
.
path
.
remove
(
base_path
)
sys
.
path
.
remove
(
base_path
)
if
verbosity
is
3
:
if
verbosity
is
0
:
from
lettuce.plugins
import
shell_output
from
lettuce.plugins
import
non_verbose
as
output
reload
(
shell_output
)
elif
verbosity
is
3
:
from
lettuce.plugins
import
shell_output
as
output
else
:
from
lettuce.plugins
import
colored_shell_output
as
output
if
verbosity
is
4
:
reload
(
output
)
from
lettuce.plugins
import
colored_shell_output
reload
(
colored_shell_output
)
self
.
output
=
output
def
run
(
self
):
def
run
(
self
):
""" Find and load step definitions, and them find and load
""" Find and load step definitions, and them find and load
features under `base_path` specified on constructor
features under `base_path` specified on constructor
"""
"""
self
.
loader
.
find_and_load_step_definitions
()
self
.
loader
.
find_and_load_step_definitions
()
for
callback
in
CALLBACK_REGISTRY
[
'all'
][
'before'
]:
for
callback
in
CALLBACK_REGISTRY
[
'all'
][
'before'
]:
callback
()
callback
()
results
=
[]
results
=
[]
for
filename
in
self
.
loader
.
find_feature_files
():
features_files
=
self
.
loader
.
find_feature_files
()
if
not
features_files
:
self
.
output
.
print_no_features_found
(
self
.
loader
.
base_dir
)
return
for
filename
in
features_files
:
feature
=
Feature
.
from_file
(
filename
)
feature
=
Feature
.
from_file
(
filename
)
results
.
append
(
feature
.
run
())
results
.
append
(
feature
.
run
())
...
...
lettuce/plugins/colored_shell_output.py
View file @
41ceafa8
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
re
import
re
import
sys
import
sys
from
lettuce.terrain
import
after
from
lettuce.terrain
import
after
...
@@ -79,3 +80,14 @@ def print_end(total):
...
@@ -79,3 +80,14 @@ def print_end(total):
total
.
steps_passed
total
.
steps_passed
)
)
)
)
def
print_no_features_found
(
where
):
where
=
os
.
path
.
relpath
(
where
)
if
not
where
.
startswith
(
os
.
sep
):
where
=
'.
%
s
%
s'
%
(
os
.
sep
,
where
)
sys
.
stdout
.
write
(
'
\033
[1;31mOops!
\033
[0m
\n
'
)
sys
.
stdout
.
write
(
'
\033
[1;37mcould not find features at '
'
\033
[1;33m
%
s
\033
[0m
\n
'
%
where
)
lettuce/plugins/non_verbose.py
0 → 100644
View file @
41ceafa8
# -*- coding: utf-8 -*-
# <Lettuce - Behaviour Driven Development for python>
# Copyright (C) <2010> Gabriel Falcão <gabriel@nacaolivre.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
logging
from
lettuce.terrain
import
after
from
lettuce.terrain
import
before
@before.each_step
def
print_step_running
(
step
):
logging
.
info
(
step
.
represent_string
(
step
.
sentence
))
@after.each_step
def
print_step_ran
(
step
):
logging
.
info
(
"
\033
[A"
+
step
.
represent_string
(
step
.
sentence
))
@before.each_scenario
def
print_scenario_running
(
scenario
):
logging
.
info
(
scenario
.
represented
())
@before.each_feature
def
print_feature_running
(
feature
):
logging
.
info
(
"
\n
"
)
logging
.
info
(
feature
.
represented
())
logging
.
info
(
"
\n
"
)
@after.all
def
print_end
(
total
):
logging
.
info
(
"
\n
"
)
word
=
total
.
features_ran
>
1
and
"features"
or
"feature"
logging
.
info
(
"
%
d
%
s (
%
d passed)
\n
"
%
(
total
.
features_ran
,
word
,
total
.
features_passed
)
)
word
=
total
.
scenarios_ran
>
1
and
"scenarios"
or
"scenario"
logging
.
info
(
"
%
d
%
s (
%
d passed)
\n
"
%
(
total
.
scenarios_ran
,
word
,
total
.
scenarios_passed
)
)
word
=
total
.
steps
>
1
and
"steps"
or
"step"
logging
.
info
(
"
%
d
%
s (
%
d passed)
\n
"
%
(
total
.
steps
,
word
,
total
.
steps_passed
)
)
def
print_no_features_found
(
where
):
where
=
os
.
path
.
relpath
(
where
)
if
not
where
.
startswith
(
os
.
sep
):
where
=
'.
%
s
%
s'
%
(
os
.
sep
,
where
)
logging
.
info
(
'
\033
[1;31mOops!
\033
[0m
\n
'
)
logging
.
info
(
'
\033
[1;37mcould not find features at '
'
\033
[1;33m
%
s
\033
[0m
\n
'
%
where
)
lettuce/plugins/shell_output.py
View file @
41ceafa8
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
sys
import
sys
from
lettuce.terrain
import
after
from
lettuce.terrain
import
after
from
lettuce.terrain
import
before
from
lettuce.terrain
import
before
...
@@ -62,3 +63,15 @@ def print_end(total):
...
@@ -62,3 +63,15 @@ def print_end(total):
total
.
steps_passed
total
.
steps_passed
)
)
)
)
def
print_no_features_found
(
where
):
where
=
os
.
path
.
relpath
(
where
)
if
not
where
.
startswith
(
os
.
sep
):
where
=
'.
%
s
%
s'
%
(
os
.
sep
,
where
)
sys
.
stdout
.
write
(
'Oops!
\n
'
)
sys
.
stdout
.
write
(
'could not find features at '
'
%
s
\n
'
%
where
)
lettuce/script.py
View file @
41ceafa8
...
@@ -38,7 +38,9 @@ def main(args=sys.argv[1:]):
...
@@ -38,7 +38,9 @@ def main(args=sys.argv[1:]):
if
args
:
if
args
:
base_path
=
os
.
path
.
abspath
(
args
[
0
])
base_path
=
os
.
path
.
abspath
(
args
[
0
])
runner
=
lettuce
.
Runner
(
base_path
,
int
(
options
.
verbosity
))
if
isinstance
(
options
.
verbosity
,
int
):
options
.
verbosity
=
int
(
options
.
verbosity
)
runner
=
lettuce
.
Runner
(
base_path
,
options
.
verbosity
)
runner
.
run
()
runner
.
run
()
...
...
tests/functional/test_runner.py
View file @
41ceafa8
...
@@ -19,7 +19,7 @@ import sys
...
@@ -19,7 +19,7 @@ import sys
from
StringIO
import
StringIO
from
StringIO
import
StringIO
from
os.path
import
dirname
,
abspath
,
join
from
os.path
import
dirname
,
abspath
,
join
,
relpath
from
nose.tools
import
assert_equals
,
with_setup
from
nose.tools
import
assert_equals
,
with_setup
from
lettuce
import
Runner
,
CALLBACK_REGISTRY
,
STEP_REGISTRY
from
lettuce
import
Runner
,
CALLBACK_REGISTRY
,
STEP_REGISTRY
...
@@ -268,3 +268,16 @@ def test_output_with_success_colorful_many_features():
...
@@ -268,3 +268,16 @@ def test_output_with_success_colorful_many_features():
"
\033
[1;37m2 scenarios (
\033
[1;32m2 passed
\033
[1;37m)
\033
[0m
\n
"
\
"
\033
[1;37m2 scenarios (
\033
[1;32m2 passed
\033
[1;37m)
\033
[0m
\n
"
\
"
\033
[1;37m4 steps (
\033
[1;32m4 passed
\033
[1;37m)
\033
[0m
\n
"
"
\033
[1;37m4 steps (
\033
[1;32m4 passed
\033
[1;37m)
\033
[0m
\n
"
)
)
@with_setup
(
prepare_stdout
)
def
test_output_when_could_not_find_features
():
"Testing the colorful output of many successful features"
path
=
relpath
(
join
(
abspath
(
dirname
(
__file__
)),
'unexistent-folder'
))
runner
=
Runner
(
path
,
verbosity
=
4
)
runner
.
run
()
assert_stdout_lines
(
'
\033
[1;31mOops!
\033
[0m
\n
'
'
\033
[1;37mcould not find features at
\033
[1;33m
%
s
\033
[0m
\n
'
%
path
)
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