Skip to content

Commit

Permalink
Renamed function to match the file name according to checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
Khusro-S committed Dec 29, 2024
1 parent 3429b31 commit db329b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion solutions/is_leap_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""


def is_leap(year) -> bool:
def is_leap_year(year) -> bool:
"""Determines if the given year is a leap year.
Parameters:
Expand Down
24 changes: 12 additions & 12 deletions solutions/tests/test_is_leap_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import unittest

from ..is_leap_year import is_leap
from ..is_leap_year import is_leap_year


class TestLeapYear(unittest.TestCase):
Expand All @@ -25,53 +25,53 @@ class TestLeapYear(unittest.TestCase):
# Standard test cases
def test_leap_year_2000(self):
"""It should return True for the year 2000 (divisible by 400)"""
self.assertTrue(is_leap(2000))
self.assertTrue(is_leap_year(2000))

def test_non_leap_year_1990(self):
"""It should return False for the year 1990 (not divisible by 4)"""
self.assertFalse(is_leap(1990))
self.assertFalse(is_leap_year(1990))

def test_non_leap_year_2100(self):
"""It should return False for the year 2100 (divisible by 100 but not by 400)"""
self.assertFalse(is_leap(2100))
self.assertFalse(is_leap_year(2100))

def test_leap_year_2004(self):
"""It should return True for the year 2004 (divisible by 4 but not by 100)"""
self.assertTrue(is_leap(2004))
self.assertTrue(is_leap_year(2004))

# Edge cases
def test_leap_year_4(self):
"""It should return True for the year 4 (the smallest leap year)"""
self.assertTrue(is_leap(4))
self.assertTrue(is_leap_year(4))

def test_non_leap_year_1(self):
"""It should return False for the year 1 (not divisible by 4)"""
self.assertFalse(is_leap(1))
self.assertFalse(is_leap_year(1))

def test_non_leap_year_100(self):
"""It should return False for the year 100 (divisible by 100 but not by 400)"""
self.assertFalse(is_leap(100))
self.assertFalse(is_leap_year(100))

# Defensive tests
def test_string_input(self):
"""It should raise AssertionError for a string input"""
with self.assertRaises(AssertionError):
is_leap("2000")
is_leap_year("2000")

def test_negative_year(self):
"""It should raise AssertionError for a negative year"""
with self.assertRaises(AssertionError):
is_leap(-4)
is_leap_year(-4)

def test_none_input(self):
"""It should raise AssertionError for None input"""
with self.assertRaises(AssertionError):
is_leap(None)
is_leap_year(None)

def test_float_input(self):
"""It should raise AssertionError for a float input"""
with self.assertRaises(AssertionError):
is_leap(4.5)
is_leap_year(4.5)


if __name__ == "__main__":
Expand Down

0 comments on commit db329b8

Please sign in to comment.