-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_harness.py
30 lines (26 loc) · 1.04 KB
/
test_harness.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
"""
Test harness:
Utility functions for writing test cases in Python programs.
Python has a standard module, unittest, that provides a more
powerful but but more complex testing framework. This module
is designed to be very simple.
Currently test_harness provides just one function, testEQ,
for comparing an actual value to an expected value. More
functions may be provided later.
Author: M Young, [email protected]
October 2012 for CIS 210 at U. Oregon
"""
def testEQ( desc, actual, expect ) :
"""General framework for running a single test case
with an expected result. Prints a log message depending
on whether the actual result was the same as the expected result.
Args:
desc: Description of the test case
actual: Actual result (should be same as expected)
expect: Expected result
"""
if actual == expect :
print(" Passed -- ",desc, " result: ", actual)
else:
print("***FAILED*** ", desc, " Expected: |", expect,
"| but got |", actual, "|")