forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
for leap_year import leap_year | ||
|
||
class TestLeapYear(unittest.TestCase): | ||
""" | ||
Test cases for the leap_year function | ||
""" | ||
|
||
def test_divisibility_by_4(self): | ||
""" | ||
Tests a year is divisible by 4 but not 100 | ||
""" | ||
self. assertTrue(leap_year(2024)) | ||
|
||
def test_not_leap_divisible_by_100(self): | ||
""" | ||
Tests a year divisible by 100 but not 400 | ||
""" | ||
self.assertFalse(leap_year(1900)) | ||
|
||
def test_leap_divisible_by_400(self): | ||
""" | ||
Tests a year divisible by 400 | ||
""" | ||
self.assertTrue(leap_year(2000)) | ||
|
||
def test_not_leap_not_divisble_by_4(self): | ||
""" | ||
Tests a year not divisble by 4 | ||
""" | ||
self.assertFalse(2023) | ||
|
||
def test_invalid_type(self): | ||
""" | ||
A ValueError should be raised if type is not integer | ||
""" | ||
with self.assertRaises(ValueError): | ||
leap_year("hi") | ||
|
||
def test_invalid_negative(self): | ||
""" | ||
A value error must be rasied if the year is a negative integer | ||
""" | ||
with self.assertRaises(ValueError): | ||
leap_year(-175) | ||
|
||
if __name__=="__main__": | ||
unittest.main() |