Skip to content

Instantly share code, notes, and snippets.

@shlaikov
Created December 10, 2016 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shlaikov/93e4ae7dd236a82d128dd6640ab38815 to your computer and use it in GitHub Desktop.
Save shlaikov/93e4ae7dd236a82d128dd6640ab38815 to your computer and use it in GitHub Desktop.
Unit test for function is_even()
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