equal
deleted
inserted
replaced
12 # FOR A PARTICULAR PURPOSE. |
12 # FOR A PARTICULAR PURPOSE. |
13 # |
13 # |
14 ############################################################################## |
14 ############################################################################## |
15 |
15 |
16 """ |
16 """ |
17 Generic Test case for ztfy.utils doctest |
17 Generic test case for pyams_utils doctests |
18 """ |
18 """ |
19 |
|
20 __docformat__ = 'restructuredtext' |
|
21 |
19 |
22 import doctest |
20 import doctest |
23 import os |
21 import os |
24 import unittest |
22 import unittest |
25 |
23 |
26 from pyams_utils.tests import get_package_dir |
24 from pyams_utils.tests import get_package_dir |
27 |
25 |
|
26 __docformat__ = 'restructuredtext' |
|
27 |
28 |
28 |
29 CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) |
29 CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) |
30 |
30 |
31 |
31 |
32 def doc_suite(test_dir, setUp=None, tearDown=None, globs=None): # pylint: disable=invalid-name |
32 def doc_suite(test_dir, setUp=None, tearDown=None, globs=None): # pylint: disable=invalid-name |
33 """Returns a test suite, based on doctests found in /doctest.""" |
33 """Returns a test suite, based on doctests found in /doctests""" |
34 suite = [] |
34 suite = [] |
35 if globs is None: |
35 if globs is None: |
36 globs = globals() |
36 globs = globals() |
37 |
37 |
38 flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | |
38 flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | |
41 package_dir = get_package_dir(test_dir) |
41 package_dir = get_package_dir(test_dir) |
42 doctest_dir = os.path.join(package_dir, 'doctests') |
42 doctest_dir = os.path.join(package_dir, 'doctests') |
43 |
43 |
44 # filtering files on extension |
44 # filtering files on extension |
45 docs = [os.path.join(doctest_dir, doc) for doc in |
45 docs = [os.path.join(doctest_dir, doc) for doc in |
46 os.listdir(doctest_dir) if doc.endswith('.txt')] |
46 os.listdir(doctest_dir) if doc.endswith('.txt') or doc.endswith('.rst')] |
47 |
47 |
48 for test in docs: |
48 for test in docs: |
49 suite.append(doctest.DocFileSuite(test, optionflags=flags, |
49 suite.append(doctest.DocFileSuite(test, optionflags=flags, |
50 globs=globs, setUp=setUp, |
50 globs=globs, setUp=setUp, |
51 tearDown=tearDown, |
51 tearDown=tearDown, |