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
b06f5ab2
Commit
b06f5ab2
authored
Oct 12, 2012
by
Gabriel Falcao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first step on parsing backgrounds appropriately
parent
b13cbb30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
+33
-1
lettuce/core.py
+5
-1
tests/unit/test_feature_parser.py
+28
-0
No files found.
lettuce/core.py
View file @
b06f5ab2
...
@@ -987,8 +987,11 @@ class Feature(object):
...
@@ -987,8 +987,11 @@ class Feature(object):
if
not
re
.
search
(
self
.
language
.
background
,
joined
):
if
not
re
.
search
(
self
.
language
.
background
,
joined
):
return
joined
,
None
return
joined
,
None
parts
=
strings
.
split_wisely
(
joined
,
self
.
language
.
background
)
parts
=
strings
.
split_wisely
(
joined
,
"(
%
s):
\
s*"
%
self
.
language
.
background
)
description
=
parts
.
pop
(
0
)
description
=
parts
.
pop
(
0
)
if
parts
:
parts
=
""
.
join
(
parts
[
1
:])
.
splitlines
()
return
description
,
parts
return
description
,
parts
...
@@ -1009,6 +1012,7 @@ class Feature(object):
...
@@ -1009,6 +1012,7 @@ class Feature(object):
if
not
re
.
search
(
"^"
+
scenario_prefix
,
joined
):
if
not
re
.
search
(
"^"
+
scenario_prefix
,
joined
):
description
,
background_lines
=
self
.
_extract_desc_and_bg
(
parts
[
0
])
description
,
background_lines
=
self
.
_extract_desc_and_bg
(
parts
[
0
])
background
=
background_lines
and
Background
.
from_string
(
background
=
background_lines
and
Background
.
from_string
(
background_lines
,
background_lines
,
self
,
self
,
...
...
tests/unit/test_feature_parser.py
View file @
b06f5ab2
...
@@ -19,6 +19,7 @@ from lettuce import step
...
@@ -19,6 +19,7 @@ from lettuce import step
from
lettuce.core
import
Scenario
from
lettuce.core
import
Scenario
from
lettuce.core
import
Feature
from
lettuce.core
import
Feature
from
lettuce.core
import
Background
from
lettuce.core
import
Background
from
lettuce.core
import
HashList
from
nose.tools
import
assert_equals
from
nose.tools
import
assert_equals
FEATURE1
=
"""
FEATURE1
=
"""
...
@@ -629,3 +630,30 @@ def test_background_parsing():
...
@@ -629,3 +630,30 @@ def test_background_parsing():
)
)
expect
(
feature
)
.
to
.
have
.
property
(
'background'
)
.
being
.
a
(
Background
)
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