[Zope3-checkins] SVN: Zope3/trunk/src/ Integrated newer version of
zdaemon that has more robust tests.
Jim Fulton
jim at zope.com
Mon Oct 31 14:08:20 EST 2005
Log message for revision 39777:
Integrated newer version of zdaemon that has more robust tests.
Changed:
_U Zope3/trunk/src/
_U Zope3/trunk/src/zope/
U Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py
U Zope3/trunk/src/zope/app/testing/functional.py
U Zope3/trunk/src/zope/app/traversing/ftests/test_vhosting.py
U Zope3/trunk/src/zope/security/checker.py
U Zope3/trunk/src/zope/security/tests/test_checker.py
-=-
Property changes on: Zope3/trunk/src
___________________________________________________________________
Name: svn:externals
- ZConfig svn://svn.zope.org/repos/main/ZConfig/tags/ZConfig-2.3.1
zdaemon svn://svn.zope.org/repos/main/zdaemon/tags/zdaemon-1.1
BTrees svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/BTrees
persistent svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/persistent
ThreadedAsync svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/ThreadedAsync
transaction svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/transaction
ZEO svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/ZEO
ZODB svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/ZODB
twisted svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted
+ ZConfig svn://svn.zope.org/repos/main/ZConfig/tags/ZConfig-2.3.1
BTrees svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/BTrees
persistent svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/persistent
ThreadedAsync svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/ThreadedAsync
transaction svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/transaction
ZEO svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/ZEO
ZODB svn://svn.zope.org/repos/main/ZODB/tags/3.6.0b2/src/ZODB
twisted svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted
zdaemon -r 39732 svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon
Property changes on: Zope3/trunk/src/zope
___________________________________________________________________
Name: svn:externals
- testing svn://svn.zope.org/repos/main/zope.testing/tags/snapshot-2005-10-10/src/zope/testing
+ testing -r39736 svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -27,6 +27,17 @@
def setUp(test):
placelesssetup.setUp()
+ meta = '''
+ <configure
+ xmlns:meta="http://namespaces.zope.org/meta"
+ i18n_domain="zope">
+ <meta:provides feature="devmode" />
+ <include package="zope.app" file="meta.zcml" />
+ <include package="zope.app" file="menus.zcml" />
+ </configure>
+ '''
+ xmlconfig.string(meta)
+
meta = os.path.join(os.path.dirname(zope.app.__file__), 'meta.zcml')
context = xmlconfig.file(meta, zope.app)
context.provideFeature('devmode')
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -25,6 +25,7 @@
from zope.interface import implements
from zope.schema import Bool
+import zope.security.checker
from zope.app.traversing.api import traverse
@@ -35,10 +36,6 @@
bar = Bool(title=u'Bar')
-registerEditForm(IFoo, widgets={
- 'bar': { 'class': 'zope.app.form.browser.BooleanRadioWidget' }})
-
-
class Foo(Persistent):
implements(IFoo)
@@ -46,11 +43,13 @@
def __init__(self):
self.bar = True
-defineSecurity(Foo, IFoo)
-
-
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(IFoo, widgets={
+ 'bar': { 'class': 'zope.app.form.browser.BooleanRadioWidget' }})
+ defineSecurity(Foo, IFoo)
def test_display_editform(self):
self.getRootFolder()['foo'] = Foo()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -23,6 +23,7 @@
from zope.interface import implements
from zope.schema import Bool
+import zope.security.checker
from zope.app.form.browser import CheckBoxWidget
from support import *
@@ -39,10 +40,6 @@
b2 = Bool(
required=False)
-
-registerEditForm(IBoolTest)
-
-
class BoolTest(Persistent):
implements(IBoolTest)
@@ -51,12 +48,14 @@
self.b1 = True
self.b2 = False
-defineSecurity(BoolTest, IBoolTest)
-
-
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(IBoolTest)
+ defineSecurity(BoolTest, IBoolTest)
+
def test_display_editform(self):
self.getRootFolder()['test'] = BoolTest()
transaction.commit()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -26,6 +26,7 @@
from zope.interface import implements
from zope.schema import Datetime, Choice
+import zope.security.checker
from support import *
from zope.app.traversing.api import traverse
@@ -50,9 +51,6 @@
min=datetime(2003, 1, 1, tzinfo=tzinfo(0)),
max=datetime(2020, 12, 31, tzinfo=tzinfo(0)))
-registerEditForm(IDatetimeTest)
-
-
class DatetimeTest(Persistent):
implements(IDatetimeTest)
@@ -62,9 +60,6 @@
self.d2 = datetime(2003, 8, 6, tzinfo=tzinfo(0))
self.d3 = None
-defineSecurity(DatetimeTest, IDatetimeTest)
-
-
def getDateForField(field, source):
"""Returns a datetime object for the specified field in source.
@@ -91,6 +86,10 @@
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(IDatetimeTest)
+ defineSecurity(DatetimeTest, IDatetimeTest)
def test_display_editform(self):
self.getRootFolder()['test'] = DatetimeTest()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -23,6 +23,7 @@
from zope.interface import implements
from zope.schema import TextLine
+import zope.security.checker
from support import *
from zope.app.traversing.api import traverse
@@ -35,20 +36,16 @@
optional_text = TextLine(required=False)
required_text = TextLine(required=True)
-
-registerEditForm(IFoo)
-
-
class Foo(Persistent):
implements(IFoo)
-
-defineSecurity(Foo, IFoo)
-
-
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(IFoo)
+ defineSecurity(Foo, IFoo)
def test_rollback_on_error(self):
"""Tests rollback when a widget error occurs.
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -25,6 +25,7 @@
from zope.schema.interfaces import IField
from zope.schema import Field
+import zope.security.checker
from zope.app.form.browser.textwidgets import FileWidget
@@ -42,18 +43,11 @@
implements(IFileField)
-
-defineWidgetView(IFileField, FileWidget, IInputWidget)
-
-
class IFileTest(Interface):
f1 = FileField(required=True)
f2 = FileField(required=False)
-registerEditForm(IFileTest)
-
-
class FileTest(Persistent):
implements(IFileTest)
@@ -62,9 +56,7 @@
self.f1 = None
self.f2 = 'foo'
-defineSecurity(FileTest, IFileTest)
-
class SampleTextFile(StringIO):
def __init__(self, buf, filename=''):
@@ -80,6 +72,11 @@
emptyFileName = 'empty.txt'
emptyFile = SampleTextFile('', emptyFileName)
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ defineWidgetView(IFileField, FileWidget, IInputWidget)
+ registerEditForm(IFileTest)
+ defineSecurity(FileTest, IFileTest)
def test_display_editform(self):
self.getRootFolder()['test'] = FileTest()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -25,6 +25,7 @@
from zope.interface import implements
from zope.schema import Float, Choice
+import zope.security.checker
from zope.app.traversing.api import traverse
@@ -46,9 +47,7 @@
values=(0.0, 1.1, 2.1, 3.1, 5.1, 7.1, 11.1),
missing_value=0)
-registerEditForm(IFloatTest)
-
class FloatTest(Persistent):
implements(IFloatTest)
@@ -58,11 +57,13 @@
self.f2 = 1.1
self.f3 = 2.1
-defineSecurity(FloatTest, IFloatTest)
-
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(IFloatTest)
+ defineSecurity(FloatTest, IFloatTest)
def test_display_editform(self):
self.getRootFolder()['test'] = FloatTest()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -25,6 +25,7 @@
from zope.interface import implements
from zope.schema import Int, Choice
+import zope.security.checker
from zope.app.traversing.api import traverse
@@ -46,9 +47,7 @@
min=1,
max=10)
-registerEditForm(IIntTest)
-
class IIntTest2(Interface):
"""Used to test an unusual care where missing_value is -1 and
not in allowed_values."""
@@ -58,9 +57,7 @@
missing_value=-1,
values=(10, 20, 30))
-registerEditForm(IIntTest2)
-
class IntTest(Persistent):
implements(IIntTest)
@@ -70,9 +67,7 @@
self.i2 = 1
self.i3 = 2
-defineSecurity(IntTest, IIntTest)
-
class IntTest2(Persistent):
implements(IIntTest2)
@@ -80,11 +75,15 @@
def __init__(self):
self.i1 = 10
-defineSecurity(IntTest2, IIntTest2)
-
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(IIntTest)
+ registerEditForm(IIntTest2)
+ defineSecurity(IntTest, IIntTest)
+ defineSecurity(IntTest2, IIntTest2)
def test_display_editform(self):
self.getRootFolder()['test'] = IntTest()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_objectwidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -20,6 +20,7 @@
from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
from zope.schema import Object, TextLine
+import zope.security.checker
from zope.app.form.browser import ObjectWidget
from zope.app.testing.functional import BrowserTestCase
from zope.app.form.browser.tests import support
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -23,6 +23,7 @@
from zope.interface import implements
from zope.schema import Text
+import zope.security.checker
from support import *
from zope.app.traversing.api import traverse
@@ -44,9 +45,7 @@
min_length=2,
max_length=10)
-registerEditForm(ITextTest)
-
class TextTest(Persistent):
implements(ITextTest)
@@ -56,11 +55,13 @@
self.s2 = u'foo'
self.s3 = None
-defineSecurity(TextTest, ITextTest)
-
class Test(BrowserTestCase):
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(ITextTest)
+ defineSecurity(TextTest, ITextTest)
def test_display_editform(self):
self.getRootFolder()['test'] = TextTest()
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -21,6 +21,7 @@
from zope.interface import Interface, implements
from zope.schema import TextLine, Choice
+import zope.security.checker
from support import *
from zope.app.traversing.api import traverse
@@ -43,9 +44,7 @@
min_length=2,
max_length=10)
-registerEditForm(ITextLineTest)
-
class TextLineTest(Persistent):
implements(ITextLineTest)
@@ -55,11 +54,15 @@
self.s2 = u'foo'
self.s3 = None
-defineSecurity(TextLineTest, ITextLineTest)
-
class Test(BrowserTestCase):
+
+ def setUp(self):
+ BrowserTestCase.setUp(self)
+ registerEditForm(ITextLineTest)
+ defineSecurity(TextLineTest, ITextLineTest)
+
def test_display_editform(self):
self.getRootFolder()['test'] = TextLineTest()
transaction.commit()
Modified: Zope3/trunk/src/zope/app/testing/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/functional.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/testing/functional.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -18,6 +18,7 @@
$Id$
"""
import logging
+import os.path
import re
import rfc822
import sys
@@ -181,10 +182,52 @@
"""Returns the Zope application instance."""
return self.app
+class ZCMLLayer:
+ """ZCML-defined test layer
+ """
+ __bases__ = ()
+
+ def __init__(self, config_file, module, name):
+ self.config_file = config_file
+ self.__module__ = module
+ self.__name__ = name
+
+ def setUp(self):
+ FunctionalTestSetup(self.config_file)
+
+ def tearDown(self):
+ raise NotImplementedError
+
+def defineLayer(name, zcml='test.zcml'):
+ """Helper function for defining layers.
+
+ Usage: defineLater('foo')
+ """
+ globals = sys._getframe(1).f_globals
+ globals[name] = FTestingLayer(
+ os.path.join(os.path.split(globals['__file__'])[0], 'test.zcml'),
+ globals['__name__'],
+ name,
+ )
+
+if os.path.exists(os.path.join('etc', 'ftesting.zcml')):
+ Functional = os.path.join('etc', 'ftesting.zcml')
+elif os.path.exists('ftesting.zcml'):
+ Functional = 'ftesting.zcml'
+else:
+ raise IOError("No such file or directory: 'ftesting.zcml'")
+
+Functional = os.path.abspath(Functional)
+
+Functional = ZCMLLayer(
+ Functional, __name__, 'Functional')
+
class FunctionalTestCase(unittest.TestCase):
"""Functional test case."""
+ layer = Functional
+
def setUp(self):
"""Prepares for a functional test case."""
super(FunctionalTestCase, self).setUp()
@@ -590,7 +633,10 @@
| doctest.REPORT_NDIFF
| doctest.NORMALIZE_WHITESPACE)
- return doctest.DocFileSuite(*paths, **kw)
+ suite = doctest.DocFileSuite(*paths, **kw)
+ suite.layer = Functional
+ return suite
+
if __name__ == '__main__':
unittest.main()
Modified: Zope3/trunk/src/zope/app/traversing/ftests/test_vhosting.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/ftests/test_vhosting.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/app/traversing/ftests/test_vhosting.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -22,7 +22,7 @@
from zope.app.publisher.browser.resource import Resource
from zope.app.traversing.api import traverse
from zope.security.checker import defineChecker, NamesChecker, NoProxy
-from zope.security.checker import _checkers
+from zope.security.checker import _checkers, undefineChecker
from zope.app.container.contained import Contained
from zope.app.zptpage.zptpage import ZPTPage
@@ -30,10 +30,17 @@
def __getitem__(self, key):
return traverse(self, '/foo/bar/' + key)
-defineChecker(MyObj, NoProxy)
class TestVirtualHosting(functional.BrowserTestCase):
+ def setUp(self):
+ functional.BrowserTestCase.setUp(self)
+ defineChecker(MyObj, NoProxy)
+
+ def tearDown(self):
+ functional.BrowserTestCase.tearDown(self)
+ undefineChecker(MyObj)
+
def test_request_url(self):
self.addPage('/pt', u'<span tal:replace="request/URL"/>')
self.verify('/pt', 'http://localhost/pt\n')
Modified: Zope3/trunk/src/zope/security/checker.py
===================================================================
--- Zope3/trunk/src/zope/security/checker.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/security/checker.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -376,6 +376,22 @@
raise DuplicationError(type_)
_checkers[type_] = checker
+def defineChecker(type_, checker):
+ """Define a checker for a given type of object
+
+ The checker can be a Checker, or a function that, when called with
+ an object, returns a Checker.
+ """
+ if not isinstance(type_, (type, types.ClassType, types.ModuleType)):
+ raise TypeError(
+ 'type_ must be a type, class or module, not a %s' % type_)
+ if type_ in _checkers:
+ raise DuplicationError(type_)
+ _checkers[type_] = checker
+
+def undefineChecker(type_):
+ del _checkers[type_]
+
NoProxy = object()
# _checkers is a mapping.
Modified: Zope3/trunk/src/zope/security/tests/test_checker.py
===================================================================
--- Zope3/trunk/src/zope/security/tests/test_checker.py 2005-10-31 18:35:15 UTC (rev 39776)
+++ Zope3/trunk/src/zope/security/tests/test_checker.py 2005-10-31 19:08:20 UTC (rev 39777)
@@ -29,7 +29,7 @@
from zope.security.proxy import removeSecurityProxy
from zope.security.proxy import getChecker
from zope.security.proxy import Proxy
-from zope.security.checker import defineChecker, ProxyFactory
+from zope.security.checker import defineChecker, undefineChecker, ProxyFactory
from zope.security.checker import canWrite, canAccess
from zope.security.checker import BasicTypes, _checkers, NoProxy, _clear
import types, pickle
@@ -369,6 +369,19 @@
self.assert_(type(proxy) is Proxy)
self.assert_(getChecker(proxy) is specific_checker)
+ def test_define_and_undefineChecker(self):
+ class SomeClass(object):
+ pass
+ obj = SomeClass()
+
+ checker = NamesChecker()
+ from zope.security.checker import _defaultChecker, selectChecker
+ self.assert_(selectChecker(obj) is _defaultChecker)
+ defineChecker(SomeClass, checker)
+ self.assert_(selectChecker(obj) is checker)
+ undefineChecker(SomeClass)
+ self.assert_(selectChecker(obj) is _defaultChecker)
+
def test_ProxyFactory_using_proxy(self):
class SomeClass(object):
pass
More information about the Zope3-Checkins
mailing list