[Zope3-checkins]
SVN: zope.testing/trunk/src/zope/testing/testrunner
Added tests for test_suite functions without returns and test suites
Jim Fulton
jim at zope.com
Sun Oct 9 14:38:34 EDT 2005
Log message for revision 39021:
Added tests for test_suite functions without returns and test suites
that don't contain tests or test suites.
Changed:
U zope.testing/trunk/src/zope/testing/testrunner-edge-cases.txt
A zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_suite.py
A zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_test.py
U zope.testing/trunk/src/zope/testing/testrunner.py
-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner-edge-cases.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-edge-cases.txt 2005-10-09 16:34:35 UTC (rev 39020)
+++ zope.testing/trunk/src/zope/testing/testrunner-edge-cases.txt 2005-10-09 18:38:33 UTC (rev 39021)
@@ -42,8 +42,8 @@
Ran 9 tests with 0 failures and 0 errors in 0.000 seconds.
...
-Debugging
----------
+Debugging Edge Cases
+--------------------
>>> class Input:
... def __init__(self, src):
@@ -414,3 +414,42 @@
Tearing down left over layers:
Tear down samplelayers.Layer1 in 0.000 seconds.
False
+
+Test Suites with None for suites or tests
+-----------------------------------------
+
+ >>> sys.argv = ['test',
+ ... '--tests-pattern', '^sampletests_none_suite$',
+ ... ]
+ >>> testrunner.run(defaults)
+ Test-module import failures:
+ <BLANKLINE>
+ Module: sample1.sampletests_none_suite
+ <BLANKLINE>
+ TypeError: Invalid test_suite, None, in sample1.sampletests_none_suite
+ <BLANKLINE>
+ <BLANKLINE>
+ Total: 0 tests, 0 failures, 0 errors
+ <BLANKLINE>
+ Test-modules with import problems:
+ sample1.sampletests_none_suite
+ True
+
+
+ >>> sys.argv = ['test',
+ ... '--tests-pattern', '^sampletests_none_test$',
+ ... ]
+ >>> testrunner.run(defaults)
+ Test-module import failures:
+ <BLANKLINE>
+ Module: sample1.sampletests_none_test
+ <BLANKLINE>
+ TypeError: Invalid test, None,
+ in test_suite from sample1.sampletests_none_test
+ <BLANKLINE>
+ <BLANKLINE>
+ Total: 0 tests, 0 failures, 0 errors
+ <BLANKLINE>
+ Test-modules with import problems:
+ sample1.sampletests_none_test
+ True
Added: zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_suite.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_suite.py 2005-10-09 16:34:35 UTC (rev 39020)
+++ zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_suite.py 2005-10-09 18:38:33 UTC (rev 39021)
@@ -0,0 +1,20 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Sample tests with a layer that can't be torn down
+
+$Id$
+"""
+
+def test_suite():
+ pass
Property changes on: zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_suite.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_test.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_test.py 2005-10-09 16:34:35 UTC (rev 39020)
+++ zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_test.py 2005-10-09 18:38:33 UTC (rev 39021)
@@ -0,0 +1,24 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Sample tests with a layer that can't be torn down
+
+$Id$
+"""
+
+import unittest
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(None)
+ return suite
Property changes on: zope.testing/trunk/src/zope/testing/testrunner-ex/sample1/sampletests_none_test.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py 2005-10-09 16:34:35 UTC (rev 39020)
+++ zope.testing/trunk/src/zope/testing/testrunner.py 2005-10-09 18:38:33 UTC (rev 39021)
@@ -762,6 +762,7 @@
yield (suite, layer)
break
+
def find_suites(options):
for fpath in find_test_files(options):
for prefix in options.prefix:
@@ -782,13 +783,34 @@
else:
try:
suite = getattr(module, options.suite_name)()
+ if isinstance(suite, unittest.TestSuite):
+ check_suite(suite, module_name)
+ else:
+ raise TypeError(
+ "Invalid test_suite, %r, in %s"
+ % (suite, module_name)
+ )
except:
suite = StartUpFailure(
options, module_name, sys.exc_info()[:2]+(None,))
+
yield suite
break
+def check_suite(suite, module_name):
+ for x in suite:
+ if isinstance(x, unittest.TestSuite):
+ check_suite(x, module_name)
+ elif not isinstance(x, unittest.TestCase):
+ raise TypeError(
+ "Invalid test, %r,\nin test_suite from %s"
+ % (x, module_name)
+ )
+
+
+
+
class StartUpFailure:
def __init__(self, options, module, exc_info):
More information about the Zope3-Checkins
mailing list