[Zope3-checkins] CVS: Zope3/src/zope/thread/tests - __init__.py:1.1.2.1 test_thread.py:1.1.2.1

Marius Gedminas marius at pov.lt
Wed Mar 3 12:36:29 EST 2004


Update of /cvs-repository/Zope3/src/zope/thread/tests
In directory cvs.zope.org:/tmp/cvs-serv22235/src/zope/thread/tests

Added Files:
      Tag: mgedmin-events2-branch
	__init__.py test_thread.py 
Log Message:
Added zope.thread -- support for thread globals like site and interaction.



=== Added File Zope3/src/zope/thread/tests/__init__.py ===
#
# This file is necessary to make this directory a package.


=== Added File Zope3/src/zope/thread/tests/test_thread.py ===
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Unit tests for zope.thread.

$Id: test_thread.py,v 1.1.2.1 2004/03/03 17:36:28 mgedmin Exp $
"""

import unittest
from zope.interface.verify import verifyObject


class ThreadStub:
    pass


class TestThread(unittest.TestCase):

    def test_ThreadGlobals(self):
        from zope.thread import ThreadGlobals
        from zope.thread.interfaces import IInteractionThreadGlobal
        from zope.thread.interfaces import ISiteThreadGlobal
        globals = ThreadGlobals()
        verifyObject(IInteractionThreadGlobal, globals)
        verifyObject(ISiteThreadGlobal, globals)

    def test_thread_globals(self):
        from zope.thread import thread_globals
        from zope.thread.interfaces import IInteractionThreadGlobal
        fake_thread = ThreadStub()
        another_thread = ThreadStub()
        globals = thread_globals(fake_thread)
        verifyObject(IInteractionThreadGlobal, globals)
        self.assert_(thread_globals(fake_thread) is globals)
        self.assert_(thread_globals(another_thread) is not globals)


def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestThread))
    return suite


if __name__ == '__main__':
    unittest.main()





More information about the Zope3-Checkins mailing list