root / logilab.pylintinstaller / logilab / pylintinstaller / tests / test_installerdocs.py

Revision 202:d67e86292521, 2.1 kB (checked in by tziade@…, 11 months ago)

added logilab.pylintinstaller

Line 
1# -*- coding: utf-8 -*-
2# Copyright (c) 2008 Tarek Ziade
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to the
16# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17"""
18Generic Test case for logilab.installer doctest
19"""
20__docformat__ = 'restructuredtext'
21
22import unittest
23import doctest
24import sys
25import os
26
27from zope.testing import doctest
28
29current_dir = os.path.dirname(__file__)
30
31def doc_suite(test_dir, setUp=None, tearDown=None, globs=None):
32    """Returns a test suite, based on doctests found in /doctest."""
33    suite = []
34    if globs is None:
35        globs = globals()
36
37    flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
38             doctest.REPORT_ONLY_FIRST_FAILURE)
39
40    package_dir = os.path.split(test_dir)[0]
41    if package_dir not in sys.path:
42        sys.path.append(package_dir)
43
44    doctest_dir = os.path.join(package_dir, 'doctests')
45
46    # filtering files on extension
47    docs = [os.path.join(doctest_dir, doc) for doc in
48            os.listdir(doctest_dir) if doc.endswith('.txt')]
49
50    for test in docs:
51        suite.append(doctest.DocFileSuite(test, optionflags=flags, 
52                                          globs=globs, setUp=setUp, 
53                                          tearDown=tearDown,
54                                          module_relative=False))
55
56    return unittest.TestSuite(suite)
57
58def test_suite():
59    """returns the test suite"""
60    return doc_suite(current_dir)
61
62if __name__ == '__main__':
63    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the browser.