-
Notifications
You must be signed in to change notification settings - Fork 264
/
doctests.py
40 lines (35 loc) · 1.08 KB
/
doctests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import doctest
import os
import unittest
import warnings
# Note loader and ignore are required arguments for unittest even if unused.
def load_tests(loader, tests, ignore):
"""
Locates and returns a collection of unittests in a TestSuite object
Parameters
----------
loader :
A required but unused parameter.
tests :
A unittest TestSuite object for collecting the needed test cases.
ignore :
A required but unused parameter.
Returns
-------
tests :
A unittest TestSuite object that holds test cases.
"""
for root, dirs, files in os.walk("."):
for f in files:
if f.endswith(".rst"):
tests.addTests(
doctest.DocFileSuite(
# ELLIPSIS option tells doctest to ignore portions of the verification value.
os.path.join(root, f),
optionflags=doctest.ELLIPSIS,
)
)
return tests
if __name__ == "__main__":
warnings.simplefilter("ignore")
unittest.main()