forked from errbotio/errbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·36 lines (30 loc) · 1.21 KB
/
run_tests.py
File metadata and controls
executable file
·36 lines (30 loc) · 1.21 KB
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
#!/usr/bin/env python
import sys
import os
from glob import glob
TRAVIS_INCOMPATIBLE = ('webhooks_tests.py',)
# Set nose verbosity level to verbose by default
os.environ['NOSE_VERBOSE'] = os.environ.get('NOSE_VERBOSE', "2")
try:
import nose
except ImportError:
sys.stderr.write("Tests require the 'nose' package which you are currently missing.\nYou can install nose with `pip install nose`.\n")
sys.exit(1)
# Webhooks tests fail when run together with the other tests, but pass correctly
# when run in isolation. We work around this issue by running each set of tests
# separately. It's an ugly hack, but it works.
segments = ('tests', '*.py')
testsuites = glob(os.sep.join(segments))
testresults = []
for testsuite in testsuites:
if os.environ.get("TRAVIS", "False") == "true" and os.path.basename(testsuite) in TRAVIS_INCOMPATIBLE:
print("Incompatible test {} skipped".format(testsuite))
continue
print("\nRunning tests from {}\n".format(testsuite))
testresults.append(nose.run(defaultTest=testsuite))
if False in testresults:
print("\nSome tests failed to pass!")
exit(-99) # a test did not pass
else:
print("\nAll tests have successfully passed")
exit(0) # no error