root / PyCon07 / test_docs.py

Revision 23:47dd00865471, 0.9 kB (checked in by Tarek Ziad?? <tarek@…>, 17 months ago)

added test fmw

  • Property exe set to *
Line 
1#!/usr/bin/python
2# -*- coding: UTF-8 -*-
3import doctest
4import unittest
5import os
6
7flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
8         doctest.REPORT_ONLY_FIRST_FAILURE)
9
10def getTextFiles(path):
11    """grab all text files and return a list of absolute paths"""
12    textfiles = []
13    for root, dirs, files in os.walk(path):
14        for filename in files:
15            if not filename.endswith('.txt'):
16                continue
17            textfiles.append(os.path.realpath(os.path.join(root, filename)))
18    return textfiles
19   
20def test_suite():
21    suite = []
22    path = os.path.dirname(__file__)
23    if path == '':
24        path = '.'
25    for testfile in getTextFiles(path):
26        suite.append(doctest.DocFileTest(testfile, optionflags=flags,
27                                         module_relative=False))
28    return unittest.TestSuite(suite)
29
30if __name__ == '__main__':
31    unittest.main(defaultTest='test_suite')
32   
Note: See TracBrowser for help on using the browser.