Skip to content

Commit

Permalink
Add bonus question for step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomwing committed May 28, 2016
1 parent 74089f2 commit 5e63c37
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
20 changes: 20 additions & 0 deletions catinabox/catmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ def cat_years_to_hooman_years(age_in_cat_years):
a long human lifespan.
"""
return age_in_cat_years * NUM_HOOMAN_YEARS_IN_CAT_YEAR


def is_cat_leap_year(year):
"""Returns True iff. year is a cat leap year.
Args:
year (int): a cat year (which is basically the same as a human year)
Returns:
bool: True iff. the cat year is a leap cat year.
"""
if year % 4 != 0:
return False
elif year % 100 != 0:
return True
elif year % 400 != 0:
return False
else:
return True
6 changes: 6 additions & 0 deletions steps/2-simple_function.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ If you get stuck, [take a peek at the solution](https://github.com/keeppythonwei
```

When the tests run successfully, you should see an increase in coverage!

5. (Optional) Bonus: Try to write some tests for ```is_cat_leap_year```. Are
you sufficiently convinced that this function works now? Why or why not?

We'd love to have a discussion about this with you if you get this far. Every
developer will have different opinions about this :)
8 changes: 7 additions & 1 deletion tests/test_catmath.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# from catinabox import catmath
from catinabox import catmath


def test__cat_years_to_hooman_years__middle_age__succeeds():
Expand All @@ -11,3 +11,9 @@ def test__cat_years_to_hooman_years__less_than_one_year__succeeds():

def test__cat_years_to_hooman_years__0__returns_0():
assert True


# BONUS MATERIAL FOR STEP 2

def test__is_cat_leap_year__succeeds():
assert catmath.is_cat_leap_year(2016) is True

0 comments on commit 5e63c37

Please sign in to comment.