forked from pydna-group/pydna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests_old.py
executable file
·49 lines (42 loc) · 1.38 KB
/
run_tests_old.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
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import doctest
import os
import sys
import os.path
import pkgutil
os.environ["PYTHONDONTWRITEBYTECODE"] = "True"
sys.dont_write_bytecode = True
os.environ["pydna_cache"] = "nocache"
import pydna
def load_tests(loader, tests, pattern):
return load_my_tests()
def load_my_tests():
suite = unittest.TestSuite()
for all_test_suite in unittest.defaultTestLoader.discover("."):
for test_suite in all_test_suite:
suite.addTests(test_suite)
finder = doctest.DocTestFinder()
pkgpath = os.path.dirname(pydna.__file__)
for _,name,_ in [n for n in pkgutil.iter_modules((pkgpath,)) if n[1]!="gel"]:
n="pydna.{}".format(name)
my_module_with_doctests = __import__(n, None, None, n.split("."))
for tst in finder.find(my_module_with_doctests):
suite.addTest(doctest.DocTestCase(tst))
del my_module_with_doctests
return suite
def main():
cwd = os.getcwd()
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(os.path.join(dname,"tests"))
print "Python version:", sys.version
print "Operating system:", os.name, sys.platform
print "running unit tests and doctests"
print
runner = unittest.TextTestRunner(verbosity = 3)
unittest.main(testRunner=runner)
os.chdir(cwd)
if __name__ == '__main__':
main()