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

Last change on this file since 1005 was 1005, checked in by mylan, 15 years ago

Import package: Copied http://svn.quintagroup.com/products/qtheme.template/trunk@2041 + modifications concerning changed package name, namespace

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