Back to index

plone3  3.1.7
test_functional.py
Go to the documentation of this file.
00001 """
00002     CMFPlone functional doctests.  This module collects all *.txt
00003     files in the tests directory and runs them.
00004 
00005     See also ``test_doctests.py``.
00006 
00007 """
00008 
00009 import os
00010 import glob
00011 from zope.testing import doctest
00012 import unittest
00013 from Globals import package_home
00014 from Testing.ZopeTestCase import FunctionalDocFileSuite as Suite
00015 from Products.CMFPlone.tests import PloneTestCase, GLOBALS
00016 
00017 UNITTESTS = ['messages.txt', 'mails.txt']
00018 
00019 OPTIONFLAGS = (doctest.ELLIPSIS |
00020                doctest.NORMALIZE_WHITESPACE)
00021 
00022 def list_doctests():
00023     home = package_home(GLOBALS)
00024     return [filename for filename in
00025             glob.glob(os.path.sep.join([home, '*.txt']))
00026             if os.path.basename(filename) not in UNITTESTS]
00027 
00028 def test_suite():
00029     filenames = list_doctests()
00030 
00031     suites = [Suite(os.path.basename(filename),
00032                optionflags=OPTIONFLAGS,
00033                package='Products.CMFPlone.tests',
00034                test_class=PloneTestCase.FunctionalTestCase)
00035               for filename in filenames]
00036 
00037     return unittest.TestSuite(suites)
00038