Back to index

plone3  3.1.7
Functions | Variables
Archetypes.tests.doctestcase Namespace Reference

Functions

def ZopeDocTestSuite

Variables

string __author__ = 'Christian Heimes'
 Copyright (c) 2002-2005, Benjamin Saller bcsal.nosp@m.ler@.nosp@m.ideas.nosp@m.uite.nosp@m..com, and the respective authors.
string __docformat__ = 'restructuredtext'
tuple __all__ = ('ZopeDocTestSuite',)

Function Documentation

def Archetypes.tests.doctestcase.ZopeDocTestSuite (   modules,
  kw 
)
Based on Sid's FunctionalDocFileSuite

Definition at line 64 of file doctestcase.py.

00064 
00065 def ZopeDocTestSuite(*modules, **kw):
00066     """Based on Sid's FunctionalDocFileSuite
00067     """
00068     test_class = kw.get('test_class', ZopeTestCase)
00069     suite = kw.get('suite', None)
00070     suite_class = kw.get('suite_class', unittest.TestSuite)
00071 
00072     for var in ('test_class', 'suite', 'suite_class',):
00073         if var in kw:
00074             del kw[var]
00075 
00076     # Fix for http://zope.org/Collectors/Zope/2178
00077     if hasattr(test_class, 'layer'):
00078         layer = test_class.layer
00079     else:
00080         layer = None
00081 
00082     # If the passed-in test_class doesn't subclass base.TestCase,
00083     # we mix it in for you, but we will issue a warning.
00084     if not issubclass(test_class, TestCase):
00085         name = test_class.__name__
00086         warnings.warn(("The test_class you are using doesn't "
00087                        "subclass from base.TestCase. "
00088                        "Please fix that."), UserWarning, 2)
00089         if not 'ZDT' in name:
00090             name = 'ZDT%s' % name
00091         test_class = type(name, (TestCase, test_class), {})
00092 
00093     # If the test_class does not have a runTest attribute, 
00094     # we add one.
00095     #if not hasattr(test_class, 'runTest'):
00096     setattr(test_class, 'runTest', None)
00097 
00098     # Create a TestCase instance which will be used
00099     # to execute the setUp and tearDown methods, as well as
00100     # be passed into the test globals as 'self'.
00101     test_instance = test_class()
00102 
00103     # setUp
00104     kwsetUp = kw.get('setUp')
00105     def setUp(test):
00106         test_instance.setUp()
00107         test.globs['test'] = test
00108         test.globs['self'] = test_instance
00109         test.globs['app'] = test_instance.app
00110         if hasattr(test_instance, 'portal'):
00111             test.globs['portal'] = test_instance.portal
00112         if kwsetUp is not None:
00113             kwsetUp(test_instance)
00114 
00115     kw['setUp'] = setUp
00116     
00117     # tearDown
00118     kwtearDown = kw.get('tearDown')
00119     def tearDown(test):
00120         if kwtearDown is not None:
00121             kwtearDown(test_instance)
00122         test_instance.tearDown()
00123 
00124     kw['tearDown'] = tearDown
00125     
00126     # other options
00127     if 'optionflags' not in kw:
00128         kw['optionflags'] = (doctest.ELLIPSIS
00129                              | doctest.NORMALIZE_WHITESPACE)
00130 
00131     if suite is None:
00132         suite = suite_class()
00133 
00134     for module in modules:
00135         suite.addTest(doctest.DocTestSuite(module, **kw))
00136 
00137     if layer is not None:
00138         suite.layer = layer
00139 
00140     return suite

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 141 of file doctestcase.py.

string Archetypes.tests.doctestcase.__author__ = 'Christian Heimes'

Copyright (c) 2002-2005, Benjamin Saller bcsal.nosp@m.ler@.nosp@m.ideas.nosp@m.uite.nosp@m..com, and the respective authors.

All rights reserved. For a list of Archetypes contributors see docs/CREDITS.txt.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    • Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Definition at line 42 of file doctestcase.py.

string Archetypes.tests.doctestcase.__docformat__ = 'restructuredtext'

Definition at line 43 of file doctestcase.py.