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
7436c4bf
Commit
7436c4bf
authored
Jul 30, 2011
by
Chris Morgan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor lettuce.terrain.before and after significantly - make them instances, not classes.
parent
75cb38b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
46 deletions
+23
-46
lettuce/terrain.py
+23
-46
No files found.
lettuce/terrain.py
View file @
7436c4bf
...
@@ -18,6 +18,7 @@ from lettuce.registry import world
...
@@ -18,6 +18,7 @@ from lettuce.registry import world
from
lettuce.registry
import
CALLBACK_REGISTRY
from
lettuce.registry
import
CALLBACK_REGISTRY
world
.
_set
=
True
world
.
_set
=
True
def
absorb
(
thing
,
name
=
None
):
def
absorb
(
thing
,
name
=
None
):
if
not
isinstance
(
name
,
basestring
):
if
not
isinstance
(
name
,
basestring
):
name
=
thing
.
__name__
name
=
thing
.
__name__
...
@@ -27,6 +28,7 @@ def absorb(thing, name=None):
...
@@ -27,6 +28,7 @@ def absorb(thing, name=None):
world
.
absorb
=
absorb
world
.
absorb
=
absorb
@world.absorb
@world.absorb
def
spew
(
name
):
def
spew
(
name
):
if
hasattr
(
world
,
name
):
if
hasattr
(
world
,
name
):
...
@@ -34,54 +36,29 @@ def spew(name):
...
@@ -34,54 +36,29 @@ def spew(name):
delattr
(
world
,
name
)
delattr
(
world
,
name
)
return
item
return
item
class
main
(
object
):
@classmethod
def
all
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'all'
,
cls
.
__name__
,
function
)
return
function
@classmethod
def
each_step
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'step'
,
"
%
s_each"
%
cls
.
__name__
,
function
)
return
function
@classmethod
def
each_scenario
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'scenario'
,
"
%
s_each"
%
cls
.
__name__
,
function
)
return
function
@classmethod
def
each_feature
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'feature'
,
"
%
s_each"
%
cls
.
__name__
,
function
)
return
function
@classmethod
def
harvest
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'harvest'
,
cls
.
__name__
,
function
)
return
function
@classmethod
def
each_app
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'app'
,
"
%
s_each"
%
cls
.
__name__
,
function
)
return
function
@classmethod
def
runserver
(
cls
,
function
):
CALLBACK_REGISTRY
.
append_to
(
'runserver'
,
cls
.
__name__
,
function
)
return
function
@classmethod
class
Main
(
object
):
def
handle_request
(
cls
,
function
):
def
__init__
(
self
,
callback
):
CALLBACK_REGISTRY
.
append_to
(
'handle_request'
,
cls
.
__name__
,
function
)
self
.
name
=
callback
return
function
@classmethod
@classmethod
def
outline
(
cls
,
function
):
def
_add_method
(
cls
,
name
,
where
,
when
):
CALLBACK_REGISTRY
.
append_to
(
'scenario'
,
"outline"
,
function
)
def
method
(
self
,
fn
):
return
function
CALLBACK_REGISTRY
.
append_to
(
where
,
when
.
format
(
self
.
name
),
fn
)
method
.
__name__
=
method
.
fn_name
=
name
setattr
(
cls
,
name
,
method
)
class
before
(
main
):
for
name
,
where
,
when
in
(
pass
(
'all'
,
'all'
,
'{0}'
),
(
'each_step'
,
'step'
,
'{0}_each'
),
(
'each_scenario'
,
'scenario'
,
'{0}_each'
),
(
'each_feature'
,
'feature'
,
'{0}_each'
),
(
'harvest'
,
'harvest'
,
'{0}'
),
(
'each_app'
,
'app'
,
'{0}_each'
),
(
'runserver'
,
'runserver'
,
'{0}'
),
(
'handle_request'
,
'handle_request'
,
'{0}'
),
(
'outline'
,
'scenario'
,
'outline'
)):
Main
.
_add_method
(
name
,
where
,
when
)
class
after
(
main
):
before
=
Main
(
'before'
)
pass
after
=
Main
(
'after'
)
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