Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
94378e23
Commit
94378e23
authored
Jun 29, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved the way the test web server is handled.
Added an api for registering tearDown handlers.
parent
f0d72696
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+21
-4
No files found.
src/zc/buildout/testing.py
View file @
94378e23
...
...
@@ -105,12 +105,15 @@ def buildoutSetUp(test, clear_home=True):
get
=
get
,
__original_wd__
=
os
.
getcwd
(),
__temporary_directories__
=
temporary_directories
,
__tearDown__
=
[],
mkdtemp
=
mkdtemp
,
))
def
buildoutTearDown
(
test
):
for
d
in
test
.
globs
[
'__temporary_directories__'
]:
shutil
.
rmtree
(
d
)
for
f
in
test
.
globs
[
'__tearDown__'
]:
f
()
os
.
chdir
(
test
.
globs
[
'__original_wd__'
])
if
test
.
globs
.
get
(
'_oldhome'
)
is
not
None
:
os
.
environ
[
'HOME'
]
=
test
.
globs
[
'_oldhome'
]
...
...
@@ -290,17 +293,31 @@ def get_port():
s
.
close
()
raise
RuntimeError
,
"Can't find port"
def
start_server
(
tree
):
def
_start_server
(
tree
,
name
=
''
):
port
=
get_port
()
threading
.
Thread
(
target
=
_run
,
args
=
(
tree
,
port
)).
start
()
thread
=
threading
.
Thread
(
target
=
_run
,
args
=
(
tree
,
port
),
name
=
name
)
thread
.
setDaemon
(
True
)
thread
.
start
()
wait
(
port
,
up
=
True
)
return
port
return
port
,
thread
def
start_server
(
tree
):
return
_start_server
(
tree
)[
0
]
def
stop_server
(
url
):
def
stop_server
(
url
,
thread
=
None
):
try
:
urllib2
.
urlopen
(
url
+
'__stop__'
)
except
Exception
:
pass
if
thread
is
not
None
:
thread
.
join
()
# wait for thread to stop
def
setUpServer
(
test
,
tree
):
port
,
thread
=
_start_server
(
tree
,
name
=
test
.
name
)
link_server
=
'http://localhost:%s/'
%
port
test
.
globs
[
'link_server'
]
=
link_server
test
.
globs
[
'__tearDown__'
].
append
(
lambda
:
stop_server
(
link_server
,
thread
))
def
wait
(
port
,
up
):
addr
=
'localhost'
,
port
...
...
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