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
d4fa678b
Commit
d4fa678b
authored
Oct 14, 2012
by
Gabriel Falcao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring background parsing
parent
a0594c89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
4 deletions
+60
-4
lettuce/core.py
+8
-3
tests/unit/test_feature_parser.py
+52
-1
No files found.
lettuce/core.py
View file @
d4fa678b
...
@@ -993,10 +993,15 @@ class Feature(object):
...
@@ -993,10 +993,15 @@ class Feature(object):
joined
,
"(
%
s):
\
s*"
%
self
.
language
.
background
)
joined
,
"(
%
s):
\
s*"
%
self
.
language
.
background
)
description
=
parts
.
pop
(
0
)
description
=
parts
.
pop
(
0
)
if
not
re
.
search
(
self
.
language
.
background
,
description
)
and
parts
:
parts
=
""
.
join
(
parts
[
1
:])
.
splitlines
()
return
description
,
parts
if
not
re
.
search
(
self
.
language
.
background
,
description
):
if
parts
:
parts
=
parts
[
1
:]
else
:
description
=
""
background_string
=
""
.
join
(
parts
)
.
splitlines
()
return
description
,
background_string
def
_parse_remaining_lines
(
self
,
lines
,
original_string
,
with_file
=
None
):
def
_parse_remaining_lines
(
self
,
lines
,
original_string
,
with_file
=
None
):
joined
=
u"
\n
"
.
join
(
lines
[
1
:])
joined
=
u"
\n
"
.
join
(
lines
[
1
:])
...
...
tests/unit/test_feature_parser.py
View file @
d4fa678b
...
@@ -357,6 +357,23 @@ Feature: Movie rental
...
@@ -357,6 +357,23 @@ Feature: Movie rental
Then there are 5 more left
Then there are 5 more left
"""
"""
FEATURE17
=
"""
Feature: Movie rental without MMF
Background:
Given I have the following movies in my database:
| Name | Rating | New | Available |
| Matrix Revolutions | 4 stars | no | 6 |
| Iron Man 2 | 5 stars | yes | 11 |
And the following clients:
| Name |
| John Doe |
| Foo Bar |
Scenario: Renting a featured movie
Given the client 'John Doe' rents 'Iron Man 2'
Then there are 10 more left
"""
def
test_feature_has_repr
():
def
test_feature_has_repr
():
"Feature implements __repr__ nicely"
"Feature implements __repr__ nicely"
...
@@ -621,7 +638,7 @@ def test_scenarios_parsing():
...
@@ -621,7 +638,7 @@ def test_scenarios_parsing():
])
])
def
test_background_parsing
():
def
test_background_parsing
_with_mmf
():
feature
=
Feature
.
from_string
(
FEATURE16
)
feature
=
Feature
.
from_string
(
FEATURE16
)
expect
(
feature
.
description
)
.
to
.
equal
(
expect
(
feature
.
description
)
.
to
.
equal
(
"As a rental store owner
\n
"
"As a rental store owner
\n
"
...
@@ -657,3 +674,37 @@ def test_background_parsing():
...
@@ -657,3 +674,37 @@ def test_background_parsing():
{
u'Name'
:
u'John Doe'
},
{
u'Name'
:
u'John Doe'
},
{
u'Name'
:
u'Foo Bar'
},
{
u'Name'
:
u'Foo Bar'
},
]))
]))
def
test_background_parsing_without_mmf
():
feature
=
Feature
.
from_string
(
FEATURE17
)
expect
(
feature
.
description
)
.
to
.
be
.
empty
expect
(
feature
)
.
to
.
have
.
property
(
'background'
)
.
being
.
a
(
Background
)
expect
(
feature
.
background
)
.
to
.
have
.
property
(
'steps'
)
expect
(
feature
.
background
.
steps
)
.
to
.
have
.
length_of
(
2
)
step1
,
step2
=
feature
.
background
.
steps
step1
.
sentence
.
should
.
equal
(
'Given I have the following movies in my database:'
)
step1
.
hashes
.
should
.
equal
(
HashList
(
step1
,
[
{
u'Available'
:
u'6'
,
u'Rating'
:
u'4 stars'
,
u'Name'
:
u'Matrix Revolutions'
,
u'New'
:
u'no'
,
},
{
u'Available'
:
u'11'
,
u'Rating'
:
u'5 stars'
,
u'Name'
:
u'Iron Man 2'
,
u'New'
:
u'yes'
,
},
]))
step2
.
sentence
.
should
.
equal
(
'And the following clients:'
)
step2
.
hashes
.
should
.
equal
(
HashList
(
step2
,
[
{
u'Name'
:
u'John Doe'
},
{
u'Name'
:
u'Foo Bar'
},
]))
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