Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
116b49f3
Commit
116b49f3
authored
May 07, 2005
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made sure to close the REQUEST so as not to leak REQUEST._held.
Thanks to Sidnei da Silva.
parent
ef846dc8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
18 deletions
+63
-18
lib/python/Testing/ZopeTestCase/base.py
lib/python/Testing/ZopeTestCase/base.py
+3
-0
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
+2
-0
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
+58
-18
No files found.
lib/python/Testing/ZopeTestCase/base.py
View file @
116b49f3
...
...
@@ -35,6 +35,7 @@ def app():
def
close
(
app
):
'''Closes the app's ZODB connection.'''
app
.
REQUEST
.
close
()
connections
.
close
(
app
.
_p_jar
)
...
...
@@ -118,6 +119,8 @@ class TestCase(profiler.Profiled, unittest.TestCase):
'''Clears the fixture.'''
if
call_close_hook
:
self
.
beforeClose
()
if
connections
.
contains
(
self
.
app
.
_p_jar
):
self
.
app
.
REQUEST
.
close
()
self
.
_close
()
self
.
logout
()
self
.
afterClear
()
...
...
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
View file @
116b49f3
...
...
@@ -15,6 +15,8 @@
connection pool depletion and subsequent hangs. Thanks to Balazs Ree.
- Encapsulated the ConnectionRegistry in its own module, connections.py.
Reusing the registry from other modules becomes a lot cleaner as a result.
- Made sure to close the REQUEST so as not to leak REQUEST._held. Thanks
to Sidnei da Silva.
0.9.6
- Dropped support for Zope 2.5 as it lacks the setSecurityManager() API.
...
...
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
View file @
116b49f3
...
...
@@ -283,23 +283,6 @@ class TestConnectionRegistry(base.TestCase):
assert
self
.
reg
.
contains
(
self
.
conns
[
2
])
class
TestRequestVariables
(
base
.
TestCase
):
'''Makes sure the REQUEST contains required variables'''
def
testRequestVariables
(
self
):
request
=
self
.
app
.
REQUEST
self
.
failIfEqual
(
request
.
get
(
'SERVER_NAME'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'SERVER_PORT'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'REQUEST_METHOD'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'URL'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'SERVER_URL'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'URL0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'URL1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE2'
,
''
),
''
)
class
TestListConverter
(
base
.
TestCase
):
def
testList0
(
self
):
...
...
@@ -337,6 +320,61 @@ class TestListConverter(base.TestCase):
self
.
assertRaises
(
ValueError
,
utils
.
makelist
,
dummy
())
class
TestRequestVariables
(
base
.
TestCase
):
'''Makes sure the REQUEST contains required variables'''
def
testRequestVariables
(
self
):
request
=
self
.
app
.
REQUEST
self
.
failIfEqual
(
request
.
get
(
'SERVER_NAME'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'SERVER_PORT'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'REQUEST_METHOD'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'URL'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'SERVER_URL'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'URL0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'URL1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE2'
,
''
),
''
)
import
gc
_sentinel1
=
[]
class
TestRequestGarbage1
(
base
.
TestCase
):
'''Make sure we do not leak REQUEST._held (and REQUEST.other)'''
class
Held
:
def
__del__
(
self
):
_sentinel1
.
append
(
'__del__'
)
def
afterSetUp
(
self
):
self
.
anApp
=
base
.
app
()
self
.
anApp
.
REQUEST
.
_hold
(
self
.
Held
())
def
testBaseCloseClosesRequest
(
self
):
base
.
close
(
self
.
anApp
)
gc
.
collect
()
self
.
assertEqual
(
_sentinel1
,
[
'__del__'
])
_sentinel2
=
[]
class
TestRequestGarbage2
(
base
.
TestCase
):
'''Make sure we do not leak REQUEST._held (and REQUEST.other)'''
class
Held
:
def
__del__
(
self
):
_sentinel2
.
append
(
'__del__'
)
def
afterSetUp
(
self
):
self
.
app
.
REQUEST
.
_hold
(
self
.
Held
())
def
testClearClosesRequest
(
self
):
self
.
_clear
()
gc
.
collect
()
self
.
assertEqual
(
_sentinel2
,
[
'__del__'
])
def
test_suite
():
from
unittest
import
TestSuite
,
makeSuite
suite
=
TestSuite
()
...
...
@@ -344,8 +382,10 @@ def test_suite():
suite
.
addTest
(
makeSuite
(
TestSetUpRaises
))
suite
.
addTest
(
makeSuite
(
TestTearDownRaises
))
suite
.
addTest
(
makeSuite
(
TestConnectionRegistry
))
suite
.
addTest
(
makeSuite
(
TestRequestVariables
))
suite
.
addTest
(
makeSuite
(
TestListConverter
))
suite
.
addTest
(
makeSuite
(
TestRequestVariables
))
suite
.
addTest
(
makeSuite
(
TestRequestGarbage1
))
suite
.
addTest
(
makeSuite
(
TestRequestGarbage2
))
return
suite
if
__name__
==
'__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