Skip to content

Instantly share code, notes, and snippets.

@suzzukin
Created January 12, 2022 13:54
Show Gist options
  • Save suzzukin/6890d48b048a99459036d0e6c052ffe2 to your computer and use it in GitHub Desktop.
Save suzzukin/6890d48b048a99459036d0e6c052ffe2 to your computer and use it in GitHub Desktop.
import unittest
def is_even(number):
''' Returns True if **number** is even or False if it is odd. '''
return number % 2
class TestUM(unittest.TestCase):
def test_is_boolean(self):
self.assertIsInstance(is_even(1), bool)
def test_return_true(self):
self.assertEqual(True, is_even(4))
def test_return_false(self):
self.assertEqual(False, is_even(5))
def test_even_zero(self):
self.assertTrue(is_even(0))
def test_even_negative(self):
self.assertTrue(is_even(-2))
def test_even_positive(self):
self.assertTrue(is_even(2))
def test_odd_positive(self):
self.assertFalse(is_even(3))
def test_odd_negative(self):
self.assertFalse(is_even(-3))
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment