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

Steve Alexander steve at cat-box.net
Fri Mar 19 11:33:32 EST 2004


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

Added Files:
	__init__.py test_thread.py 
Log Message:
Module to support thread global variables for Zope.


=== Zope3/src/zope/thread/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Fri Mar 19 11:33:32 2004
+++ Zope3/src/zope/thread/tests/__init__.py	Fri Mar 19 11:33:31 2004
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/thread/tests/test_thread.py 1.1 => 1.2 ===
--- /dev/null	Fri Mar 19 11:33:32 2004
+++ Zope3/src/zope/thread/tests/test_thread.py	Fri Mar 19 11:33:31 2004
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# 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$
+"""
+
+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