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
a6c27e2f
Commit
a6c27e2f
authored
Mar 27, 2011
by
David
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blank step hash become empty strings
Blank step hash become empty strings
parent
5c51567e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
3 deletions
+80
-3
lettuce/plugins/colored_shell_output.py
+1
-1
lettuce/strings.py
+5
-1
tests/asserts.py
+1
-1
tests/functional/syntax_features/blank_values_in_hash/blank_values_in_hash.feature
+11
-0
tests/functional/test_runner.py
+29
-0
tests/unit/test_strings.py
+33
-0
No files found.
lettuce/plugins/colored_shell_output.py
View file @
a6c27e2f
...
...
@@ -112,7 +112,7 @@ def print_step_ran(step):
else
:
lines_up
=
int
(
lines_up
)
+
1
prefix
=
prefix
*
lines_up
#
prefix = prefix * lines_up
if
step
.
failed
:
color
=
"
\033
[0;31m"
...
...
lettuce/strings.py
View file @
a6c27e2f
...
...
@@ -39,6 +39,10 @@ def get_stripped_lines(string, ignore_lines_starting_with=''):
def
split_wisely
(
string
,
sep
,
strip
=
False
):
string
=
unicode
(
string
)
if
strip
:
string
=
string
.
strip
()
else
:
string
=
string
.
strip
(
"
\n
"
)
sep
=
unicode
(
sep
)
regex
=
re
.
compile
(
escape_if_necessary
(
sep
),
re
.
UNICODE
|
re
.
M
|
re
.
I
)
...
...
@@ -49,7 +53,7 @@ def split_wisely(string, sep, strip=False):
else
:
items
=
[
i
.
strip
(
"
\n
"
)
for
i
in
items
]
return
[
unicode
(
i
)
for
i
in
items
if
i
]
return
[
unicode
(
i
)
for
i
in
items
]
def
wise_startswith
(
string
,
seed
):
string
=
unicode
(
string
)
...
...
tests/asserts.py
View file @
a6c27e2f
...
...
@@ -42,7 +42,7 @@ def assert_lines(original, expected):
def
assert_lines_unicode
(
original
,
expected
):
if
original
!=
expected
:
diff
=
''
.
join
(
list
(
Differ
()
.
compare
(
expected
.
splitlines
(
1
),
original
.
splitlines
(
1
))))
raise
AssertionError
,
'Output differed as follows:
\n
'
+
diff
+
"
\n
Output was:
\n
"
+
original
raise
AssertionError
,
'Output differed as follows:
\n
'
+
diff
+
"
\n
Output was:
\n
"
+
original
+
"
\n
Expected was:
\n
"
+
expected
assert_equals
(
len
(
expected
),
len
(
original
),
'Output appears equal, but of different lengths.'
)
...
...
tests/functional/syntax_features/blank_values_in_hash/blank_values_in_hash.feature
0 → 100644
View file @
a6c27e2f
Feature
:
Allow blanks in steps
Scenario
:
blank values default to blank strings
Given
I ignore step
When
I ignore step
Then the string length calc should be correct
:
|
string
|
string2
|
length
|
|
car
|
bike
|
7
|
|
|
bike
|
4
|
|
car
|
|
3
|
And
I ignore step
tests/functional/test_runner.py
View file @
a6c27e2f
...
...
@@ -1043,3 +1043,32 @@ def test_commented_scenario():
"1 step (1 passed)
\n
"
)
#with_setup(prepare_stderr)
@with_setup
(
prepare_stdout
)
def
test_blank_step_hash_value
():
"syntax checking: Blank in step hash column = empty string"
from
lettuce
import
step
@step
(
'ignore step'
)
def
append_2_more
(
step
):
pass
@step
(
'string length calc'
)
def
append_2_more
(
step
):
for
hash
in
step
.
hashes
:
if
len
(
hash
[
"string"
])
+
len
(
hash
[
"string2"
])
!=
int
(
hash
[
"length"
]):
raise
AssertionError
(
"fail"
)
filename
=
syntax_feature_name
(
'blank_values_in_hash'
)
runner
=
Runner
(
filename
,
verbosity
=
1
)
runner
.
run
()
assert_stdout_lines
(
"...."
"
\n
"
"1 feature (1 passed)
\n
"
"1 scenario (1 passed)
\n
"
"4 steps (4 passed)
\n
"
)
tests/unit/test_strings.py
View file @
a6c27e2f
...
...
@@ -253,3 +253,36 @@ def test_parse_hashes_escapes_pipes():
assert_equals
(
keys
,
got_keys
)
assert_equals
(
dicts
,
got_dicts
)
def
test_parse_hashes_allow_empty
():
"strings.parse_hashes allow empty"
keys
=
[
u'name'
,
u'age'
]
dicts
=
[
{
u'name'
:
u'Gabriel'
,
u'age'
:
u'22'
},
{
u'name'
:
u''
,
u'age'
:
u'33'
},
{
u'name'
:
u'Dave'
,
u'age'
:
u''
}
]
table
=
[
u"| name | age |
\n
"
,
u"| Gabriel | 22 |
\n
"
,
u"| | 33 |
\n
"
,
u"| Dave | |
\n
"
,
]
got_keys
,
got_dicts
=
strings
.
parse_hashes
(
table
)
assert_equals
(
keys
,
got_keys
)
assert_equals
(
dicts
,
got_dicts
)
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