I'm trying to use Python's unittest module to compare results and expected values and get test statistics in the end. However, below sample code gives me the following error:
File "...", line 16, in <module>
run_tests.test_equal()
File "...", line 13, in test_equal
self.assertEqual(self.result, self.expected)
File "/usr/lib/python2.7/unittest/case.py", line 512, in assertEqual
assertion_func = self._getAssertEqualityFunc(first, second)
File "/usr/lib/python2.7/unittest/case.py", line 493, in _getAssertEqualityFunc
asserter = self._type_equality_funcs.get(type(first))
AttributeError: 'RunTests' object has no attribute '_type_equality_funcs'
Sample code:
import unittest
class RunTests(unittest.TestCase):
def __init__(self, result, expected):
self.result = result
self.expected = expected
def runTest(self):
test_equal(self)
def test_equal(self):
self.assertEqual(self.result, self.expected)
run_tests = RunTests(9, 9)
run_tests.test_equal()
if __name__ == '__main__':
unittest.main()
How can I use the module's comparison functions on varying input values? I have found this post, but the problem appears to be different.
Thanks a lot in advance.