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
b040311f
Commit
b040311f
authored
Dec 08, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test directory and SQLAlias test suite.
parent
992b5606
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
lib/python/Shared/DC/ZRDB/test/testSQLAlias.py
lib/python/Shared/DC/ZRDB/test/testSQLAlias.py
+102
-0
No files found.
lib/python/Shared/DC/ZRDB/test/testSQLAlias.py
0 → 100755
View file @
b040311f
#!/usr/bin/env python
#----------------------------------------------------------------------
# Unit tests for SQLAlias objects
#----------------------------------------------------------------------
# __version__ = "$Revision: 1.1 $"[11:-2]
from
unittest
import
TestSuite
,
TestCase
from
Shared.DC.ZRDB.RDB
import
SQLAlias
,
NoBrains
from
Acquisition
import
Implicit
from
Record
import
Record
import
sys
,
ExtensionClass
# A plain extension class to use in comparison with the
# Record extension class.
class
TestObject
(
ExtensionClass
.
Base
):
pass
# A helper to set up an initialized TestObject.
def
make_object
():
object
=
TestObject
()
dict
=
object
.
__dict__
dict
[
'RealName'
]
=
'RealName value'
dict
[
'realname'
]
=
SQLAlias
(
'RealName'
)
return
object
# Mimic the record objects created on the fly within the
# DatabaseResults class in RDB.py with a simple schema.
class
r
(
Record
,
Implicit
,
NoBrains
,
NoBrains
):
'Result record class'
__record_schema__
=
{
'RealName'
:
0
}
# A helper to set up an initialized record object.
def
make_record
():
object
=
r
()
dict
=
object
.
__dict__
dict
[
'RealName'
]
=
'RealName value'
dict
[
'realname'
]
=
SQLAlias
(
'RealName'
)
return
object
# A helper to get the refcount of the SQLAlias class.
def
refcount
():
return
sys
.
getrefcount
(
SQLAlias
)
class
ClassMemLeakTest
(
TestCase
):
"""Test for memory leak of SQLAliases accessed through a
basic ExtensionClass instance."""
def
runTest
(
self
):
# get starting refcount
start_refs
=
refcount
()
# set up the instance with an alias, access through the
# alias, then delete the instance; refcount should be
# back to start_refs after the delete.
object
=
make_object
()
value
=
object
.
realname
del
object
# check the refcount
assert
start_refs
==
refcount
(),
\
'SQLAlias leaked after access through extension class instance!'
class
RecordMemLeakTest
(
TestCase
):
"""Test for memory leak of SQLAliases accessed through a
Record instance."""
def
runTest
(
self
):
# get starting refcount
start_refs
=
refcount
()
# set up the instance with an alias, access through the
# alias, then delete the instance; refcount should be
# back to start_refs after the delete.
object
=
make_record
()
value
=
object
.
realname
del
object
# check the refcount
assert
start_refs
==
refcount
(),
\
'SQLAlias leaked after access through a Record instance!'
def
test_suite
():
suite
=
TestSuite
()
suite
.
addTest
(
ClassMemLeakTest
())
suite
.
addTest
(
RecordMemLeakTest
())
return
suite
if
__name__
==
'__main__'
:
# Run tests if run as a standalone script
from
unittest
import
TextTestRunner
TextTestRunner
().
run
(
test_suite
())
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