forked from icarus-sim/icarus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
33 lines (26 loc) · 833 Bytes
/
test.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
"""Run unit tests
"""
from os import path, getcwd
__all__ = ['run']
def run(verbosity=1):
"""Run tests.
Parameters
----------
verbosity: integer, optional
Level of detail in test reports. Higher numbers provide more detail.
"""
try:
import nose
except ImportError:
raise ImportError("The nose package is needed to run the tests.")
# get folder of Python source files
src_dir = path.join(path.dirname(__file__), path.pardir)
# stop if running from source directory
if getcwd() == path.abspath(path.join(src_dir, path.pardir)):
raise RuntimeError("Can't run tests from source directory.\n"
"Run 'nosetests' from the command line.")
# Run tests
nose.run()
if __name__=="__main__":
run()