Created
December 10, 2016 19:36
-
-
Save shlaikov/93e4ae7dd236a82d128dd6640ab38815 to your computer and use it in GitHub Desktop.
Unit test for function is_even()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
def is_even(number): | |
return True | |
class TestCase(unittest.TestCase): | |
def setUp(self): | |
self.expected_output = [ | |
(2, True), | |
(3, False), | |
(4, True), | |
(5, False) | |
] | |
def test_is_even(self): | |
real_res = [] | |
for arg, _ in self.expected_output: | |
real_res.append((arg, is_even(arg))) | |
msg_error = '\nFor %s Expected %s Got %s' | |
msg = [] | |
for res1, res2 in zip(real_res, self.expected_output): | |
if res1[1] != res2[1]: | |
msg.append(msg_error % (res1[0], res1[1], res2[1])) | |
self.assertEqual(real_res, self.expected_output, "".join(msg)) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment