Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
7f48f417
Commit
7f48f417
authored
Sep 15, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slap test: make sure mocks/stubs are NOT leaking.
parent
82ded4e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
slapos/tests/slap.py
slapos/tests/slap.py
+11
-0
No files found.
slapos/tests/slap.py
View file @
7f48f417
...
@@ -34,6 +34,9 @@ import urlparse
...
@@ -34,6 +34,9 @@ import urlparse
import
slapos.slap
import
slapos.slap
import
xml_marshaller
import
xml_marshaller
ORIGINAL_HTTPLIB_HTTPCONNECTION
=
httplib
.
HTTPConnection
ORIGINAL_HTTPLIB_HTTPSCONNECTION
=
httplib
.
HTTPSConnection
ORIGINAL_HTTPLIB_HTTPRESPONSE
=
httplib
.
HTTPResponse
class
UndefinedYetException
(
Exception
):
class
UndefinedYetException
(
Exception
):
"""To catch exceptions which are not yet defined"""
"""To catch exceptions which are not yet defined"""
...
@@ -70,10 +73,17 @@ class SlapMixin(unittest.TestCase):
...
@@ -70,10 +73,17 @@ class SlapMixin(unittest.TestCase):
def
_unpatchHttplib
(
self
):
def
_unpatchHttplib
(
self
):
"""Restores httplib overriding"""
"""Restores httplib overriding"""
import
httplib
import
httplib
# XXX not reliable
for
name
,
original_value
in
self
.
saved_httplib
.
items
():
for
name
,
original_value
in
self
.
saved_httplib
.
items
():
setattr
(
httplib
,
name
,
original_value
)
setattr
(
httplib
,
name
,
original_value
)
del
self
.
saved_httplib
del
self
.
saved_httplib
# XXX this fixes upper code, to be sure it is reliable
httplib
.
HTTPConnection
=
ORIGINAL_HTTPLIB_HTTPCONNECTION
httplib
.
HTTPSConnection
=
ORIGINAL_HTTPLIB_HTTPSCONNECTION
httplib
.
HTTPResponse
=
ORIGINAL_HTTPLIB_HTTPRESPONSE
def
_getTestComputerId
(
self
):
def
_getTestComputerId
(
self
):
"""
"""
Returns the computer id used by the test
Returns the computer id used by the test
...
@@ -987,3 +997,4 @@ if __name__ == '__main__':
...
@@ -987,3 +997,4 @@ if __name__ == '__main__':
print
'You can point to any SLAP server by setting TEST_SLAP_SERVER_URL '
\
print
'You can point to any SLAP server by setting TEST_SLAP_SERVER_URL '
\
'environment variable'
'environment variable'
unittest
.
main
()
unittest
.
main
()
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