-
Notifications
You must be signed in to change notification settings - Fork 1
/
poc_simpletest.py
40 lines (35 loc) · 1.1 KB
/
poc_simpletest.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
"""
Lightweight testing class inspired by unittest from Pyunit
https://docs.python.org/2/library/unittest.html
Note that code is designed to be much simpler than unittest
and does NOT replicate unittest functionality
"""
class TestSuite:
"""
Create a suite of tests similar to unittest
"""
def __init__(self):
"""
Creates a test suite object
"""
self.total_tests = 0
self.failures = 0
def run_test(self, computed, expected, message = ""):
"""
Compare computed and expected
If not equal, print message, computed, expected
"""
self.total_tests += 1
if computed != expected:
msg = message + " Computed: " + str(computed)
msg += " Expected: " + str(expected)
print(msg)
self.failures += 1
def report_results(self):
"""
Report back summary of successes and failures
from run_test()
"""
msg = "Ran " + str(self.total_tests) + " tests. "
msg += str(self.failures) + " failures."
print(msg)