Skip to content

Commit

Permalink
added test file
Browse files Browse the repository at this point in the history
  • Loading branch information
Muna-S committed Jan 10, 2025
1 parent 2a54ed4 commit 1c71d93
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions solutions/tests/test_leap_year.py
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()

0 comments on commit 1c71d93

Please sign in to comment.