def test(self): class MyType(object): pass class MyType2(object): pass # When an item is added to the basic types, it should also be added to # the list of checkers. BasicTypes[MyType] = NoProxy self.assert_(MyType in _checkers) # If we clear the checkers, the type should still be there _clear() self.assert_(MyType in BasicTypes) self.assert_(MyType in _checkers) # Now delete the type from the dictionary, will also delete it from # the checkers del BasicTypes[MyType] self.assert_(MyType not in BasicTypes) self.assert_(MyType not in _checkers) # The quick way of adding new types is using update BasicTypes.update({MyType: NoProxy, MyType2: NoProxy}) self.assert_(MyType in BasicTypes) self.assert_(MyType2 in BasicTypes) self.assert_(MyType in _checkers) self.assert_(MyType2 in _checkers) # Let's remove the two new types del BasicTypes[MyType] del BasicTypes[MyType2] # Of course, BasicTypes is a full dictionary. This dictionary is by # default filled with several entries: keys = BasicTypes.keys() keys.sort() self.assert_(bool in keys) self.assert_(int in keys) self.assert_(float in keys) self.assert_(str in keys) self.assert_(unicode in keys) self.assert_(object in keys) # ... # Finally, the ``clear()`` method has been deactivated to avoid # unwanted deletions. self.assertRaises(NotImplementedError, BasicTypes.clear)
def test(self): class MyType(object): pass class MyType2(object): pass # When an item is added to the basic types, it should also be added to # the list of checkers. BasicTypes[MyType] = NoProxy self.assert_(MyType in _checkers) # If we clear the checkers, the type should still be there _clear() self.assert_(MyType in BasicTypes) self.assert_(MyType in _checkers) # Now delete the type from the dictionary, will also delete it from # the checkers del BasicTypes[MyType] self.assert_(MyType not in BasicTypes) self.assert_(MyType not in _checkers) # The quick way of adding new types is using update BasicTypes.update({MyType: NoProxy, MyType2: NoProxy}) self.assert_(MyType in BasicTypes) self.assert_(MyType2 in BasicTypes) self.assert_(MyType in _checkers) self.assert_(MyType2 in _checkers) # Let's remove the two new types del BasicTypes[MyType] del BasicTypes[MyType2] # Of course, BasicTypes is a full dictionary. This dictionary is by # default filled with several entries: keys = BasicTypes.keys() keys.sort() self.assert_(bool in keys) self.assert_(int in keys) self.assert_(float in keys) self.assert_(str in keys) self.assert_(unicode in keys) self.assert_(object in keys) # ... # Finally, the ``clear()`` method has been deactivated to avoid # unwanted deletions. self.assertRaises(NotImplementedError, BasicTypes.clear)
def tearDown(self): from zope.security.checker import _clear _clear()
def setUp(self): from zope.security.checker import _clear _clear()
def tearDown(self): from zope.security.checker import _clear _clear()
def setUp(self): from zope.security.checker import _clear _clear()
def tearDown(self): super(DecoratedSecurityCheckerDescriptorTests, self).tearDown() from zope.security.checker import _clear _clear()