Created
January 12, 2022 13:54
-
-
Save suzzukin/6890d48b048a99459036d0e6c052ffe2 to your computer and use it in GitHub Desktop.
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): | |
''' 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