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
4ebf1d6f
Commit
4ebf1d6f
authored
Mar 27, 2006
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Made base.TestCase a new-style class.
- Added placeless.py for Z3-style setup. Thanks to Whit Morriss.
parent
17a7629a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
166 additions
and
2 deletions
+166
-2
lib/python/Testing/ZopeTestCase/__init__.py
lib/python/Testing/ZopeTestCase/__init__.py
+1
-0
lib/python/Testing/ZopeTestCase/base.py
lib/python/Testing/ZopeTestCase/base.py
+1
-1
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
+3
-1
lib/python/Testing/ZopeTestCase/placeless.py
lib/python/Testing/ZopeTestCase/placeless.py
+63
-0
lib/python/Testing/ZopeTestCase/testPlaceless.py
lib/python/Testing/ZopeTestCase/testPlaceless.py
+97
-0
lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
+1
-0
No files found.
lib/python/Testing/ZopeTestCase/__init__.py
View file @
4ebf1d6f
...
@@ -51,6 +51,7 @@ from zopedoctest import FunctionalDocFileSuite
...
@@ -51,6 +51,7 @@ from zopedoctest import FunctionalDocFileSuite
import
zopedoctest
as
doctest
import
zopedoctest
as
doctest
import
transaction
import
transaction
import
placeless
Zope
=
Zope2
Zope
=
Zope2
lib/python/Testing/ZopeTestCase/base.py
View file @
4ebf1d6f
...
@@ -40,7 +40,7 @@ def close(app):
...
@@ -40,7 +40,7 @@ def close(app):
class
TestCase
(
profiler
.
Profiled
,
unittest
.
TestCase
):
class
TestCase
(
profiler
.
Profiled
,
unittest
.
TestCase
,
object
):
'''Base test case for Zope testing
'''Base test case for Zope testing
'''
'''
...
...
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
View file @
4ebf1d6f
Unreleased
2.9 edition
- transaction.commit(1) is deprecated in favor of transaction.savepoint().
- transaction.commit(1) is deprecated in favor of transaction.savepoint().
- Don't break if Python distros ship without profile support (Debian, Ubuntu).
- Don't break if Python distros ship without profile support (Debian, Ubuntu).
- Functional.publish() would hang if it got a request_method argument other
- Functional.publish() would hang if it got a request_method argument other
...
@@ -8,6 +8,8 @@ Unreleased
...
@@ -8,6 +8,8 @@ Unreleased
- Made functional doctests set cookie related headers.
- Made functional doctests set cookie related headers.
- Made functional doctests set the Www-Authenticate header.
- Made functional doctests set the Www-Authenticate header.
- Made sure logging is configured. Read $INSTANCE_HOME/log.ini if it exists.
- Made sure logging is configured. Read $INSTANCE_HOME/log.ini if it exists.
- Made base.TestCase a new-style class.
- Added placeless.py for Z3-style setup. Thanks to Whit Morriss.
0.9.8 (Zope 2.8 edition)
0.9.8 (Zope 2.8 edition)
- Renamed 'doctest' package to 'zopedoctest' because of name-shadowing
- Renamed 'doctest' package to 'zopedoctest' because of name-shadowing
...
...
lib/python/Testing/ZopeTestCase/placeless.py
0 → 100644
View file @
4ebf1d6f
##############################################################################
#
# 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.
#
##############################################################################
"""Placeless setup
$Id$
"""
from
zope.app.testing.placelesssetup
import
setUp
,
tearDown
# For convenience
from
Products.Five
import
zcml
def
callZCML
(
zcml_callback
):
if
callable
(
zcml_callback
):
zcml_callback
()
else
:
for
func
in
zcml_callback
:
func
()
def
temporaryPlacelessSetUp
(
orig_func
,
placeless_available
=
True
,
required_zcml
=
[]):
'''A wrapper for test functions that require CA to be available and/or
some ZCML to be run during test fixture creation.
'''
if
not
placeless_available
:
return
orig_func
def
wrapper
(
*
args
,
**
kw
):
__doc__
=
'''%s ::
@param required_zcml callback or iterable of callbacks
required for setup of configuration needed by fixture
creation.
'''
%
orig_func
.
__doc__
# Setup the placeless stuff that's needed to create a fixture
setUp
()
# Call any necessary callbacks for setting up ZCML
callZCML
(
required_zcml
)
if
kw
.
has_key
(
'required_zcml'
):
zcml
=
kw
.
pop
(
'required_zcml'
)
callZCML
(
zcml
)
value
=
orig_func
(
*
args
,
**
kw
)
# And tear it down
tearDown
()
return
value
return
wrapper
lib/python/Testing/ZopeTestCase/testPlaceless.py
0 → 100644
View file @
4ebf1d6f
##############################################################################
#
# 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.
#
##############################################################################
"""Placeless setup tests
$Id:$
"""
import
os
,
sys
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase.placeless
import
setUp
,
tearDown
from
Testing.ZopeTestCase.placeless
import
zcml
from
Testing.ZopeTestCase.placeless
import
temporaryPlacelessSetUp
import
Products.Five.tests
from
Products.Five.tests.adapters
import
IAdapted
from
Products.Five.tests.adapters
import
Adaptable
def
setupZCML
():
zcml
.
load_config
(
'meta.zcml'
,
Products
.
Five
)
zcml
.
load_config
(
'permissions.zcml'
,
Products
.
Five
)
zcml
.
load_config
(
'directives.zcml'
,
Products
.
Five
.
tests
)
class
TestPlacelessSetUp
(
ZopeTestCase
.
ZopeTestCase
):
'''Tests ZopeTestCase with placeless setup'''
def
afterSetUp
(
self
):
tearDown
()
def
beforeTearDown
(
self
):
tearDown
()
def
testSimple
(
self
):
# SetUp according to Five's adapter test
setUp
()
setupZCML
()
# Now we have a fixture that should work for adaptation
adapted
=
IAdapted
(
Adaptable
())
self
.
assertEqual
(
adapted
.
adaptedMethod
(),
'Adapted: The method'
)
def
func
(
self
,
*
args
):
adapted
=
IAdapted
(
Adaptable
())
return
True
def
testNoCA
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
func
)
def
testAvailableCA
(
self
):
setUp
()
setupZCML
()
self
.
assertEqual
(
self
.
func
(),
True
)
def
testDecoratorLoadsZCMLCallable
(
self
):
f
=
temporaryPlacelessSetUp
(
self
.
func
,
required_zcml
=
setupZCML
)
self
.
assertEqual
(
f
(),
True
)
def
testDecoratorLoadsZCMLIterable
(
self
):
f
=
temporaryPlacelessSetUp
(
self
.
func
,
required_zcml
=
(
setupZCML
,))
self
.
assertEqual
(
f
(),
True
)
def
testPlacelessFlagDisablesDecoration
(
self
):
f
=
temporaryPlacelessSetUp
(
self
.
func
,
placeless_available
=
False
,
required_zcml
=
setupZCML
)
self
.
assertRaises
(
TypeError
,
f
)
def
testDecoratedFuncLoadsZCMLCallable
(
self
):
f
=
temporaryPlacelessSetUp
(
self
.
func
)
self
.
assertEqual
(
f
(
required_zcml
=
setupZCML
),
True
)
def
testDecoratedFuncLoadsZCMLIterable
(
self
):
f
=
temporaryPlacelessSetUp
(
self
.
func
)
self
.
assertEqual
(
f
(
required_zcml
=
(
setupZCML
,)),
True
)
def
test_suite
():
from
unittest
import
TestSuite
,
makeSuite
suite
=
TestSuite
()
suite
.
addTest
(
makeSuite
(
TestPlacelessSetUp
))
return
suite
if
__name__
==
'__main__'
:
framework
()
lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
View file @
4ebf1d6f
...
@@ -16,5 +16,6 @@ $Id$
...
@@ -16,5 +16,6 @@ $Id$
"""
"""
from
zope.testing.doctest
import
*
from
zope.testing.doctest
import
*
from
zope.testing.doctest
import
_normalize_module
from
functional
import
*
from
functional
import
*
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