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
9f9849fc
Commit
9f9849fc
authored
Aug 24, 2015
by
Nathan Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added compiled regexes
parent
54b7d328
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
lettuce/core.py
+3
-4
lettuce/registry.py
+18
-0
No files found.
lettuce/core.py
View file @
9f9849fc
...
...
@@ -357,9 +357,9 @@ class Step(object):
def
_get_match
(
self
,
ignore_case
):
matched
,
func
=
None
,
lambda
:
None
for
regex
,
func
in
STEP_REGISTRY
.
items
():
matched
=
re
.
search
(
regex
,
self
.
sentence
,
ignore_case
and
re
.
I
or
0
)
for
step
,
func
in
STEP_REGISTRY
.
items
():
regex
=
STEP_REGISTRY
.
get_regex
(
step
,
ignore_case
)
matched
=
re
gex
.
search
(
self
.
sentence
)
if
matched
:
break
...
...
@@ -1354,4 +1354,3 @@ class SummaryTotalResults(TotalResult):
self
.
_proposed_definitions
.
extend
(
scenario_result
.
steps_undefined
)
if
len
(
scenario_result
.
steps_failed
)
>
0
:
self
.
failed_scenario_locations
.
append
(
scenario_result
.
scenario
.
represented
())
lettuce/registry.py
View file @
9f9849fc
...
...
@@ -41,6 +41,24 @@ class CallbackDict(dict):
callback_list
[:]
=
[]
class
StepDict
(
dict
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
StepDict
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
_compiled
=
{}
self
.
_compiled_ignore_case
=
{}
def
get_regex
(
self
,
step
,
ignore_case
=
False
):
if
ignore_case
:
regex
=
self
.
_compiled_ignore_case
.
get
(
step
,
None
)
if
not
regex
:
regex
=
re
.
compile
(
step
,
re
.
I
)
self
.
_compiled_ignore_case
[
step
]
=
regex
else
:
regex
=
self
.
_compiled
.
get
(
step
,
None
)
if
not
regex
:
regex
=
re
.
compile
(
step
)
self
.
_compiled
[
step
]
=
regex
return
regex
def
load
(
self
,
step
,
func
):
self
.
_assert_is_step
(
step
,
func
)
self
[
step
]
=
func
...
...
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