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
ae60ba1d
Commit
ae60ba1d
authored
Mar 15, 2007
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed broken profiler support.
parent
41e02756
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
4 additions
and
215 deletions
+4
-215
lib/python/Testing/ZopeTestCase/__init__.py
lib/python/Testing/ZopeTestCase/__init__.py
+0
-1
lib/python/Testing/ZopeTestCase/base.py
lib/python/Testing/ZopeTestCase/base.py
+1
-2
lib/python/Testing/ZopeTestCase/doc/API.stx
lib/python/Testing/ZopeTestCase/doc/API.stx
+0
-34
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
+1
-0
lib/python/Testing/ZopeTestCase/doc/PROFILER.stx
lib/python/Testing/ZopeTestCase/doc/PROFILER.stx
+0
-19
lib/python/Testing/ZopeTestCase/interfaces.py
lib/python/Testing/ZopeTestCase/interfaces.py
+0
-8
lib/python/Testing/ZopeTestCase/profiler.py
lib/python/Testing/ZopeTestCase/profiler.py
+0
-122
lib/python/Testing/ZopeTestCase/testInterfaces.py
lib/python/Testing/ZopeTestCase/testInterfaces.py
+0
-19
lib/python/Testing/ZopeTestCase/ztc_common.py
lib/python/Testing/ZopeTestCase/ztc_common.py
+2
-10
No files found.
lib/python/Testing/ZopeTestCase/__init__.py
View file @
ae60ba1d
...
...
@@ -33,7 +33,6 @@ from ZopeTestCase import FunctionalTestCase
from
PortalTestCase
import
portal_name
from
PortalTestCase
import
PortalTestCase
from
profiler
import
Profiled
from
sandbox
import
Sandboxed
from
functional
import
Functional
...
...
lib/python/Testing/ZopeTestCase/base.py
View file @
ae60ba1d
...
...
@@ -18,7 +18,6 @@ $Id$
import
ZopeLite
as
Zope2
import
unittest
import
transaction
import
profiler
import
utils
import
interfaces
import
connections
...
...
@@ -41,7 +40,7 @@ def close(app):
class
TestCase
(
profiler
.
Profiled
,
unittest
.
TestCase
,
object
):
class
TestCase
(
unittest
.
TestCase
,
object
):
'''Base test case for Zope testing
'''
...
...
lib/python/Testing/ZopeTestCase/doc/API.stx
View file @
ae60ba1d
...
...
@@ -57,8 +57,6 @@ Module Testing.ZopeTestCase
PortalTestCase
Profiled
Sandboxed
Functional
...
...
@@ -243,38 +241,6 @@ Class PortalTestCase
Module profiler
Profiling support
Functions
runcall(func, *args, **kw)
print_stats()
dump_stats(filename)
Classes
Profiled
Class Profiled
Profiling support mix-in for xTestCases
Interfaces
implements(IProfiled)
Methods
runcall(func, *args, **kw)
Module sandbox
ZODB sandbox support
...
...
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
View file @
ae60ba1d
0.9.10 (Zope 2.11 edition)
- Switched to Zope3 interfaces.
- Removed broken profiler support.
0.9.9 (Zope 2.11 edition)
- transaction.commit(1) is deprecated in favor of transaction.savepoint(1).
...
...
lib/python/Testing/ZopeTestCase/doc/PROFILER.stx
deleted
100644 → 0
View file @
41e02756
<style type="text/css"> <!-- li { margin: 1em } --> </style>
Profiler Readme
Since version 0.9.0 all xTestCases are profiler aware by default.
You can run your tests under profiler control like this::
python testSomething.py profile
If you want to profile fixture creation or destruction type one of::
python testSomething.py profile-setup
python testSomething.py profile-teardown
Profiler statistics will be printed after the test results.
See the API reference for more on the 'profiler' module.
lib/python/Testing/ZopeTestCase/interfaces.py
View file @
ae60ba1d
...
...
@@ -95,14 +95,6 @@ class IPortalSecurity(IZopeSecurity):
'''This is currently the same as IZopeSecurity'''
class
IProfiled
(
Interface
):
def
runcall
(
func
,
*
args
,
**
kw
):
'''Allows to run a function under profiler control
adding to the accumulated profiler statistics.
'''
class
IFunctional
(
Interface
):
def
publish
(
path
,
basic
=
None
,
env
=
None
,
extra
=
None
,
request_method
=
'GET'
,
stdin
=
None
):
...
...
lib/python/Testing/ZopeTestCase/profiler.py
deleted
100644 → 0
View file @
41e02756
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Profiling support for ZTC
$Id$
"""
import
os
,
sys
import
interfaces
from
zope.interface
import
implements
# Some distros ship without profile
try
:
from
profile
import
Profile
from
pstats
import
Stats
except
ImportError
:
def
Profile
():
pass
_profile
=
Profile
()
_have_stats
=
0
limit
=
(
'.py:'
,
200
)
sort
=
(
'cumulative'
,
'time'
,
'pcalls'
)
strip_dirs
=
1
def
runcall
(
*
args
,
**
kw
):
if
_profile
is
None
:
return
apply
(
args
[
0
],
args
[
1
:],
kw
)
else
:
global
_have_stats
_have_stats
=
1
return
apply
(
_profile
.
runcall
,
args
,
kw
)
def
print_stats
(
limit
=
limit
,
sort
=
sort
,
strip_dirs
=
strip_dirs
):
if
_have_stats
:
stats
=
Stats
(
_profile
)
if
strip_dirs
:
stats
.
strip_dirs
()
apply
(
stats
.
sort_stats
,
sort
)
apply
(
stats
.
print_stats
,
limit
)
def
dump_stats
(
filename
):
if
_have_stats
:
_profile
.
dump_stats
(
filename
)
class
Profiled
:
'''Derive from this class and an xTestCase to get profiling support::
class MyTest(Profiled, ZopeTestCase):
...
Then run the test module by typing::
$ python testSomething.py profile
Profiler statistics will be printed after the test results.
'''
implements
(
interfaces
.
IProfiled
)
def
runcall
(
self
,
*
args
,
**
kw
):
return
apply
(
runcall
,
args
,
kw
)
def
__call__
(
self
,
result
=
None
):
if
result
is
None
:
result
=
self
.
defaultTestResult
()
result
.
startTest
(
self
)
testMethod
=
getattr
(
self
,
self
.
_TestCase__testMethodName
)
try
:
try
:
if
int
(
os
.
environ
.
get
(
'PROFILE_SETUP'
,
0
)):
self
.
runcall
(
self
.
setUp
)
else
:
self
.
setUp
()
except
KeyboardInterrupt
:
raise
except
:
result
.
addError
(
self
,
self
.
_TestCase__exc_info
())
return
ok
=
0
try
:
if
int
(
os
.
environ
.
get
(
'PROFILE_TESTS'
,
0
)):
self
.
runcall
(
testMethod
)
else
:
testMethod
()
ok
=
1
except
self
.
failureException
:
result
.
addFailure
(
self
,
self
.
_TestCase__exc_info
())
except
KeyboardInterrupt
:
raise
except
:
result
.
addError
(
self
,
self
.
_TestCase__exc_info
())
try
:
if
int
(
os
.
environ
.
get
(
'PROFILE_TEARDOWN'
,
0
)):
self
.
runcall
(
self
.
tearDown
)
else
:
self
.
tearDown
()
except
KeyboardInterrupt
:
raise
except
:
result
.
addError
(
self
,
self
.
_TestCase__exc_info
())
ok
=
0
if
ok
:
result
.
addSuccess
(
self
)
finally
:
result
.
stopTest
(
self
)
lib/python/Testing/ZopeTestCase/testInterfaces.py
View file @
ae60ba1d
...
...
@@ -28,19 +28,12 @@ from zope.interface.verify import verifyObject
class
TestAbstractClasses
(
TestCase
):
def
testIProfiled
(
self
):
self
.
failUnless
(
verifyClass
(
IProfiled
,
Profiled
))
def
testIFunctional
(
self
):
self
.
failUnless
(
verifyClass
(
IFunctional
,
Functional
))
class
TestBaseTestCase
(
TestCase
):
def
testIProfiled
(
self
):
self
.
failUnless
(
verifyClass
(
IProfiled
,
TestCase
))
self
.
failUnless
(
verifyObject
(
IProfiled
,
self
))
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
TestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
...
...
@@ -50,10 +43,6 @@ class TestZopeTestCase(ZopeTestCase):
_setup_fixture
=
0
def
testIProfiled
(
self
):
self
.
failUnless
(
verifyClass
(
IProfiled
,
ZopeTestCase
))
self
.
failUnless
(
verifyObject
(
IProfiled
,
self
))
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
ZopeTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
...
...
@@ -71,10 +60,6 @@ class TestFunctionalTestCase(FunctionalTestCase):
self
.
failUnless
(
verifyClass
(
IFunctional
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IFunctional
,
self
))
def
testIProfiled
(
self
):
self
.
failUnless
(
verifyClass
(
IProfiled
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IProfiled
,
self
))
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
...
...
@@ -91,10 +76,6 @@ class TestPortalTestCase(PortalTestCase):
def
_portal
(
self
):
return
None
def
testIProfiled
(
self
):
self
.
failUnless
(
verifyClass
(
IProfiled
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IProfiled
,
self
))
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
...
...
lib/python/Testing/ZopeTestCase/ztc_common.py
View file @
ae60ba1d
...
...
@@ -21,7 +21,7 @@ $Id$
"""
# Overwrites the default framework() method to expose the
# TestRunner parameters
and add profiler support.
# TestRunner parameters
#
def
framework
(
stream
=
sys
.
stderr
,
descriptions
=
1
,
verbosity
=
1
):
if
__name__
!=
'__main__'
:
...
...
@@ -29,17 +29,9 @@ def framework(stream=sys.stderr, descriptions=1, verbosity=1):
if
len
(
sys
.
argv
)
>
1
:
arg
=
sys
.
argv
[
1
]
if
arg
in
(
'profile'
,
'profile-tests'
):
os
.
environ
[
'PROFILE_TESTS'
]
=
'1'
elif
arg
==
'profile-setup'
:
os
.
environ
[
'PROFILE_SETUP'
]
=
'1'
elif
arg
==
'profile-teardown'
:
os
.
environ
[
'PROFILE_TEARDOWN'
]
=
'1'
else
:
sys
.
exit
(
globals
()[
arg
]()
and
1
or
0
)
sys
.
exit
(
globals
()[
arg
]()
and
1
or
0
)
result
=
TestRunner
(
stream
,
descriptions
,
verbosity
).
run
(
test_suite
())
from
Testing.ZopeTestCase
import
profiler
;
profiler
.
print_stats
()
sys
.
exit
(
len
(
result
.
errors
)
+
len
(
result
.
failures
))
...
...
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