-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
50 lines (39 loc) · 1.61 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
PepFunNN: Protocols for the analysis of peptides using cheminformatics and bioinformatics tools
"""
########################################################################################
# Authorship
########################################################################################
__author__ = "Rodrigo Ochoa"
__email__ = "raoc@novonordisk.com"
########################################################################################
# Modules to import
########################################################################################
from unittest import TestLoader, TestResult
from pathlib import Path
##########################################################################
# Function
##########################################################################
def run_tests():
"""
Function to run all the available unittests
"""
test_loader = TestLoader()
test_result = TestResult()
test_directory = str(Path(__file__).resolve().parent / 'tests')
test_suite = test_loader.discover(test_directory, pattern='test_*.py')
test_suite.run(result=test_result)
if test_result.wasSuccessful():
print("\n################################\nAll of the tests were successful!\n################################")
exit(0)
else:
print("\nFailures:")
for i,fail in enumerate(test_result.failures):
print(f"{i+1}. {fail[0]}\n{fail[1]}")
if test_result.errors:
print("\nErrors:")
for i,error in enumerate(test_result.errors):
print(error)
exit(-1)
if __name__ == '__main__':
run_tests()