interactive-coding-challenges/arrays_strings/two_sum/test_two_sum.py

23 lines
540 B
Python
Raw Normal View History

2017-03-30 17:42:09 +08:00
from nose.tools import assert_equal, assert_raises
class TestTwoSum(object):
def test_two_sum(self):
solution = Solution()
assert_raises(TypeError, solution.two_sum, None, None)
assert_raises(ValueError, solution.two_sum, [], 0)
target = 7
nums = [1, 3, 2, -7, 5]
expected = [2, 4]
assert_equal(solution.two_sum(nums, target), expected)
print('Success: test_two_sum')
def main():
test = TestTwoSum()
test.test_two_sum()
if __name__ == '__main__':
main()