diff --git a/tests/test_catmath.py b/tests/test_catmath.py index ced6358..2a29273 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -2,18 +2,21 @@ def test__cat_years_to_hooman_years__middle_age__succeeds(): - assert True + cat_years = 10 + human_years = catmath.cat_years_to_hooman_years(cat_years) + assert human_years == 50 def test__cat_years_to_hooman_years__less_than_one_year__succeeds(): - assert True + cat_years = 0.5 + human_years = catmath.cat_years_to_hooman_years(cat_years) + assert human_years == 2.5 def test__cat_years_to_hooman_years__0__returns_0(): - assert True + assert catmath.cat_years_to_hooman_years(0) == 0 # BONUS MATERIAL FOR STEP 2 - def test__is_cat_leap_year__succeeds(): assert catmath.is_cat_leap_year(2016) is True diff --git a/tests/test_cattery.py b/tests/test_cattery.py index b36692c..3ecd863 100644 --- a/tests/test_cattery.py +++ b/tests/test_cattery.py @@ -6,34 +6,34 @@ ########################################################################### # add_cats ########################################################################### +@pytest.fixture(scope='function') +def cattery_client(): + return cattery.Cattery() -def test__add_cats__succeeds(): - c = cattery.Cattery() - c.add_cats(["Fluffy", "Snookums"]) - assert c.cats == ["Fluffy", "Snookums"] - assert c.num_cats == 2 + +def test__add_cats__succeeds(cattery_client): + cattery_client.add_cats(["Fluffy", "Snookums"]) + assert cattery_client.cats == ["Fluffy", "Snookums"] + assert cattery_client.num_cats == 2 ########################################################################### # remove_cat ########################################################################### -def test__remove_cat__succeeds(): - c = cattery.Cattery() - c.add_cats(["Fluffy", "Junior"]) - c.remove_cat("Fluffy") - assert c.cats == ["Junior"] - assert c.num_cats == 1 +def test__remove_cat__succeeds(cattery_client): + cattery_client.add_cats(["Fluffy", "Junior"]) + cattery_client.remove_cat("Fluffy") + assert cattery_client.cats == ["Junior"] + assert cattery_client.num_cats == 1 -def test__remove_cat__no_cats__fails(): - c = cattery.Cattery() +def test__remove_cat__no_cats__fails(cattery_client): with pytest.raises(cattery.CatNotFound): - c.remove_cat("Fluffles") + cattery_client.remove_cat("Fluffles") -def test__remove_cat__cat_not_in_cattery__fails(): - c = cattery.Cattery() - c.add_cats(["Fluffy"]) +def test__remove_cat__cat_not_in_cattery__fails(cattery_client): + cattery_client.add_cats(["Fluffy"]) with pytest.raises(cattery.CatNotFound): - c.remove_cat("Snookums") + cattery_client.remove_cat("Snookums") diff --git a/tests/test_safecatmath.py b/tests/test_safecatmath.py index 3f85a35..bf15d68 100644 --- a/tests/test_safecatmath.py +++ b/tests/test_safecatmath.py @@ -1,6 +1,7 @@ -# import pytest +import pytest from catinabox import safecatmath +from catinabox.safecatmath import InvalidAge def test__cat_years_to_hooman_years__middle_age__succeeds(): @@ -19,17 +20,20 @@ def test__cat_years_to_hooman_years__0__returns_0(): def test__cat_years_to_hooman_years__less_0__raises(): - assert True + with pytest.raises(InvalidAge): + safecatmath.cat_years_to_hooman_years(-1) def test__cat_years_to_hooman_years__older_than_1000__raises(): - assert True + with pytest.raises(InvalidAge): + safecatmath.cat_years_to_hooman_years(1001) def test__cat_years_to_hooman_years__string__raises(): - assert True + with pytest.raises(InvalidAge): + safecatmath.cat_years_to_hooman_years('str') def test__cat_years_to_hooman_years__nan__raises(): - # hooman_age = float('nan') - assert True + with pytest.raises(InvalidAge): + safecatmath.cat_years_to_hooman_years(float('nan'))