[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testSettings.py:1.1.2.1

Steve Alexander steve@cat-box.net
Wed, 20 Mar 2002 17:50:57 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv7531/tests

Added Files:
      Tag: Zope-3x-branch
	testSettings.py 
Log Message:
Reimplemented symbolic constants class for security settings.
Added test to check that a setting retains its identity on pickling
and unpickling.


=== Added File Zope3/lib/python/Zope/App/Security/tests/testSettings.py ===
##############################################################################
# Copyright (c) 2001 Zope Corporation and Contributors.  All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 1.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.
##############################################################################

import unittest, sys

from Zope.App.Security.Settings import Allow
from cPickle import Pickler, Unpickler
from StringIO import StringIO

class Test(unittest.TestCase):

    def testPickleUnpickle(self):
        s = StringIO()
        p = Pickler(s)
        p.dump(Allow)
        s.seek(0)
        u = Unpickler(s)
        newAllow = u.load()
        
        self.assertEqual(newAllow is Allow, 1)

def test_suite():
    loader=unittest.TestLoader()
    return loader.loadTestsFromTestCase(Test)

if __name__=='__main__':
    unittest.TextTestRunner().run(test_suite())