[z3-checkins] r22073 - in z3/Five/branch/rocky-products-less-product-loading: . tests tests/testing

rocky at codespeak.net rocky at codespeak.net
Thu Jan 12 21:06:52 CET 2006


Author: rocky
Date: Thu Jan 12 21:06:25 2006
New Revision: 22073

Added:
   z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py
   z3/Five/branch/rocky-products-less-product-loading/tests/testing/zope2module.py
Modified:
   z3/Five/branch/rocky-products-less-product-loading/   (props changed)
Log:
Added basic doctests for testing python product registration.  At the moment it is quite difficult to do full testing without depending on an actual third-party prdoucts.


Added: z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py
==============================================================================
--- (empty file)
+++ z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py	Thu Jan 12 21:06:25 2006
@@ -0,0 +1,63 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.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.
+#
+##############################################################################
+"""Python packages-as-products testing
+
+$Id$
+"""
+import os, sys
+if __name__ == '__main__':
+    execfile(os.path.join(sys.path[0], 'framework.py'))
+
+def test_registerProduct():
+    """
+    Testing registerProduct
+
+      >>> from zope.app.testing.placelesssetup import setUp, tearDown
+      >>> setUp()
+      >>> import Products
+      >>> import Products.Five
+      >>> import Products.Five.tests
+      >>> import Products.Five.tests.testing
+      >>> from Products.Five.tests.testing import zope2module
+      >>> from Products.Five import pythonproducts
+    
+    Make sure registerProduct only handles appropriate types::
+    
+      >>> pythonproducts.register_python_product(None)
+      Traceback (most recent call last):
+      ...
+      TypeError: The package argument must either be an instance of basestring or types.ModuleType
+
+      >>> pythonproducts.register_python_product('Products.Five.tests.adapters')
+      Traceback (most recent call last):
+      ...
+      AttributeError: The module 'Products' requires a Zope 2 style initialize function
+    
+      >>> pythonproducts.register_python_product(zope2module)
+      Traceback (most recent call last):
+      ...
+      ValueError: Registering a python package currently only supports filesystem based pure python packages
+                  
+    
+    Clean up:
+
+      >>> tearDown()
+    """
+
+def test_suite():
+    from Testing.ZopeTestCase import ZopeDocTestSuite
+    return ZopeDocTestSuite()
+
+if __name__ == '__main__':
+    framework()

Added: z3/Five/branch/rocky-products-less-product-loading/tests/testing/zope2module.py
==============================================================================
--- (empty file)
+++ z3/Five/branch/rocky-products-less-product-loading/tests/testing/zope2module.py	Thu Jan 12 21:06:25 2006
@@ -0,0 +1,20 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.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.
+#
+##############################################################################
+"""Simple Zope 2 style module
+
+$Id$
+"""
+
+def initialize(context):
+    print "initalized"


More information about the z3-checkins mailing list