source: products/quintagroup.themetemplate/trunk/quintagroup/themetemplate/tests/test_qthemedoc.py @ 3221

Last change on this file since 3221 was 3048, checked in by mylan, 14 years ago

#238: Removde --no-interactive option (which needed only for tests) from README

File size: 1.5 KB
Line 
1# -*- coding: utf-8 -*-
2"""
3Grabs the tests in doctest
4"""
5__docformat__ = 'restructuredtext'
6
7from zopeskel.tests.test_zopeskeldocs import *
8
9# Create patch to hide --no-interactive paster option
10# to prevent confusing of a user.
11orig_paster = paster
12def paster(cmd):
13    return orig_paster(cmd + " --no-interactive")
14
15current_dir = os.path.abspath(os.path.dirname(__file__))
16
17def doc_suite(test_dir, setUp=testSetUp, tearDown=testTearDown, globs=None):
18    """Returns a test suite, based on doctests found in /doctest."""
19    suite = []
20    if globs is None:
21        globs = globals()
22
23    flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
24             doctest.REPORT_ONLY_FIRST_FAILURE)
25
26    package_dir = os.path.split(test_dir)[0]
27    if package_dir not in sys.path:
28        sys.path.append(package_dir)
29
30    doctest_dir = package_dir
31
32    # filtering files on extension
33    docs = [os.path.join(doctest_dir, doc) for doc in
34            os.listdir(doctest_dir) if doc.endswith('.txt')]
35
36    for test in docs:
37        suite.append(doctest.DocFileSuite(test, optionflags=flags, 
38                                          globs=globs, setUp=setUp, 
39                                          tearDown=tearDown,
40                                          module_relative=False))
41
42    return unittest.TestSuite(suite)
43
44
45def test_suite():
46    """returns the test suite"""
47    suite = doc_suite(current_dir)
48    suite.layer = ZopeSkelLayer
49    return suite
50
51if __name__ == '__main__':
52    unittest.main(defaultTest='test_suite')
53
Note: See TracBrowser for help on using the repository browser.