root / classifier / tests / test_docs.py

Revision 162:ca1529c62df9, 2.0 kB (checked in by Tarek Ziad?? <tarek@…>, 12 months ago)

fixes

  • Property exe set to *
Line 
1#!/usr/bin/python
2# -*- coding: UTF-8 -*-
3#
4# Copyright (c) 2006 Emencia
5#
6#
7# Authors: Tarek Ziade <tarek@emencia.com>
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation; either version 2
12# of the License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22# $Id: test_docs.py 1110 2007-02-14 08:43:34Z tarek $
23import doctest
24import unittest
25import sys
26import os
27
28def doc_suite(test_dir, setUp=None, tearDown=None, globs=None):
29    """returns a test suite, based on docs"""
30    suite = []
31    if globs is None:
32        globs = globals()
33
34    flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
35             doctest.REPORT_ONLY_FIRST_FAILURE)
36
37    product_dir = os.path.split(test_dir)[0]
38    if product_dir not in sys.path:
39        sys.path.append(product_dir)
40
41    doc_dir = os.path.join(product_dir, 'doc')
42    #docs = [os.path.join(doc_dir, doc) for doc in
43    #        os.listdir(doc_dir) if doc.endswith('.txt')]
44    docs = [os.path.join(doc_dir, doc) for doc in
45            os.listdir(doc_dir) if doc.endswith('.txt')]
46
47    for test in docs:
48        suite.append(doctest.DocFileTest(test,
49                     optionflags=flags, globs=globs,
50                     setUp=setUp, tearDown=tearDown,
51                     module_relative=False))
52
53    return unittest.TestSuite(suite)
54
55
56#current_dir = os.path.dirname(__file__)
57current_dir = '.'
58
59def test_suite():
60    globs = globals()
61    return doc_suite(current_dir, globs=globs)
62
63if __name__ == '__main__':
64    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the browser.