1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
"""
CMFPlone functional doctests. This module collects all *.txt
files in the tests directory and runs them.
See also ``test_doctests.py``.
"""
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
import glob
from zope.testing import doctest
import unittest
from Globals import package_home
from Testing.ZopeTestCase import FunctionalDocFileSuite as Suite
from Products.CMFPlone.tests import PloneTestCase, GLOBALS
from Products.PloneTestCase.layer import ZCMLLayer
import Products.PloneTestCase.setup as setup
REQUIRE_TESTBROWSER = ['AddMoveAndDeleteDocument.txt',
'LoginAndLogout.txt']
OPTIONFLAGS = (doctest.REPORT_ONLY_FIRST_FAILURE |
doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE)
def list_doctests():
home = package_home(GLOBALS)
return [filename for filename in
glob.glob(os.path.sep.join([home, '*.txt']))]
def list_nontestbrowser_tests():
return [filename for filename in list_doctests()
if os.path.basename(filename) not in REQUIRE_TESTBROWSER]
def test_suite():
# BBB: We can obviously remove this when testbrowser is Plone
# mainstream, read: with Five 1.4.
try:
import Products.Five.testbrowser
except ImportError:
print >> sys.stderr, ("testbrowser not found; "
"testbrowser tests skipped")
filenames = list_nontestbrowser_tests()
else:
filenames = list_doctests()
suites = [Suite(os.path.basename(filename),
optionflags=OPTIONFLAGS,
package='Products.CMFPlone.tests',
test_class=PloneTestCase.FunctionalTestCase)
for filename in filenames]
if setup.USELAYER:
for s in suites:
s.layer=ZCMLLayer
return unittest.TestSuite(suites)
if __name__ == '__main__':
framework()
|