forked from nsi-iff/should-dsl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_all_examples.py
executable file
·32 lines (25 loc) · 1.02 KB
/
run_all_examples.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
#!/usr/bin/env python
import doctest
import unittest
import os
import sys
import glob
def test_suite():
flags = doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
if sys.version_info >= (3,):
flags |= doctest.IGNORE_EXCEPTION_DETAIL
doctests_path = os.path.join('should_dsl', 'doctests')
suite = unittest.TestSuite()
for doc in glob.glob('docs/*.rst') + ['README.rst']:
suite.addTest(doctest.DocFileSuite(doc, optionflags=flags))
suite.addTest(doctest.DocFileSuite('README.rst', optionflags=flags))
for doctest_file in os.listdir(doctests_path):
if doctest_file.endswith('.txt'):
suite.addTest(doctest.DocFileSuite(os.path.join(doctests_path,
doctest_file),
optionflags=flags))
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(test_suite())
sys.exit(int(bool(result.failures or result.errors)))