diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.pytest_cache/v/cache/lastfailed @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.pytest_cache/v/cache/nodeids b/.pytest_cache/v/cache/nodeids new file mode 100644 index 0000000..01e1e3d --- /dev/null +++ b/.pytest_cache/v/cache/nodeids @@ -0,0 +1,59 @@ +[ + "tests/test_catactivities.py", + "tests/test_catactivities.py", + "tests/test_catactivities.py", + "tests/test_catactivities.py::test__cat_nap__satisfying_nap", + "tests/test_catactivities.py::test__cat_nap__not_satisfying", + "tests/test_catgenerator.py", + "tests/test_catgenerator.py", + "tests/test_catgenerator.py", + "tests/test_catgenerator.py::test__", + "tests/test_catmath.py", + "tests/test_catmath.py", + "tests/test_catmath.py", + "tests/test_catmath.py::test__cat_years_to_hooman_years__middle_age__succeeds", + "tests/test_catmath.py::test__cat_years_to_hooman_years__less_than_one_year__succeeds", + "tests/test_catmath.py::test__cat_years_to_hooman_years__0__returns_0", + "tests/test_catmath.py::test__is_cat_leap_year__succeeds", + "tests/test_catmath.py::test__is_cat_leap_year_2000__succeeds", + "tests/test_catmath.py::test__is_cat_leap_year_1900__fails", + "tests/test_catmath.py::test__is_cat_leap_year_2002__fails", + "tests/test_cattery.py", + "tests/test_cattery.py", + "tests/test_cattery.py", + "tests/test_cattery.py::test__add_cats__succeeds", + "tests/test_cattery.py::test__remove_cat__succeeds", + "tests/test_cattery.py::test__remove_cat__no_cats__fails", + "tests/test_cattery.py::test__remove_cat__cat_not_in_cattery__fails", + "tests/test_safecatmath.py", + "tests/test_safecatmath.py", + "tests/test_safecatmath.py", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__middle_age__succeeds", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__less_than_one_year__succeeds", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__0__returns_0", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__less_0__raises", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__older_than_1000__raises", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__string__raises", + "tests/test_safecatmath.py::test__cat_years_to_hooman_years__nan__raises", + "catinabox/__init__.py", + "catinabox/__init__.py", + "catinabox/__init__.py", + "catinabox/catactivities.py", + "catinabox/catactivities.py", + "catinabox/catactivities.py", + "catinabox/catgenerator.py", + "catinabox/catgenerator.py", + "catinabox/catgenerator.py", + "catinabox/catmath.py", + "catinabox/catmath.py", + "catinabox/catmath.py", + "catinabox/cattery.py", + "catinabox/cattery.py", + "catinabox/cattery.py", + "catinabox/mccattery.py", + "catinabox/mccattery.py", + "catinabox/mccattery.py", + "catinabox/safecatmath.py", + "catinabox/safecatmath.py", + "catinabox/safecatmath.py" +] \ No newline at end of file diff --git a/.pytest_cache/v/flakes/mtimes b/.pytest_cache/v/flakes/mtimes new file mode 100644 index 0000000..0383884 --- /dev/null +++ b/.pytest_cache/v/flakes/mtimes @@ -0,0 +1,50 @@ +{ + "catinabox/__init__.py": [ + 1527968854.1161103, + [] + ], + "catinabox/catactivities.py": [ + 1527968854.1201196, + [] + ], + "catinabox/catgenerator.py": [ + 1527968854.1251335, + [] + ], + "catinabox/catmath.py": [ + 1527974091.0336118, + [] + ], + "catinabox/cattery.py": [ + 1527968854.1331818, + [] + ], + "catinabox/mccattery.py": [ + 1527968854.1371648, + [] + ], + "catinabox/safecatmath.py": [ + 1527968854.1412032, + [] + ], + "tests/test_catactivities.py": [ + 1528033436.5026548, + [] + ], + "tests/test_catgenerator.py": [ + 1527968854.4336014, + [] + ], + "tests/test_catmath.py": [ + 1527974087.8107457, + [] + ], + "tests/test_cattery.py": [ + 1528031199.9464488, + [] + ], + "tests/test_safecatmath.py": [ + 1528023328.4403205, + [] + ] +} \ No newline at end of file diff --git a/.pytest_cache/v/mccabe/mtimes b/.pytest_cache/v/mccabe/mtimes new file mode 100644 index 0000000..0adcc41 --- /dev/null +++ b/.pytest_cache/v/mccabe/mtimes @@ -0,0 +1,50 @@ +{ + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/__init__.py": [ + 1527968854.1161103, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catactivities.py": [ + 1527968854.1201196, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catgenerator.py": [ + 1527968854.1251335, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catmath.py": [ + 1527974091.0336118, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/cattery.py": [ + 1527968854.1331818, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/mccattery.py": [ + 1527968854.1371648, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/safecatmath.py": [ + 1527968854.1412032, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catactivities.py": [ + 1528033436.5026548, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catgenerator.py": [ + 1527968854.4336014, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catmath.py": [ + 1527974087.8107457, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ + 1528031199.9464488, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ + 1528023328.4403205, + 7 + ] +} \ No newline at end of file diff --git a/.pytest_cache/v/pep8/mtimes b/.pytest_cache/v/pep8/mtimes new file mode 100644 index 0000000..7787438 --- /dev/null +++ b/.pytest_cache/v/pep8/mtimes @@ -0,0 +1,50 @@ +{ + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/__init__.py": [ + 1527968854.1161103, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catactivities.py": [ + 1527968854.1201196, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catgenerator.py": [ + 1527968854.1251335, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catmath.py": [ + 1527974091.0336118, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/cattery.py": [ + 1527968854.1331818, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/mccattery.py": [ + 1527968854.1371648, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/safecatmath.py": [ + 1527968854.1412032, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catactivities.py": [ + 1528033436.5026548, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catgenerator.py": [ + 1527968854.4336014, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catmath.py": [ + 1527974087.8107457, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ + 1528031199.9464488, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ + 1528023328.4403205, + [] + ] +} \ No newline at end of file diff --git a/catinabox/catmath.py b/catinabox/catmath.py index b0579bb..b3b9d9e 100644 --- a/catinabox/catmath.py +++ b/catinabox/catmath.py @@ -21,11 +21,11 @@ def is_cat_leap_year(year): bool: True iff. the cat year is a leap cat year. """ - if year % 4 != 0: + if (year % 4) != 0: return False - elif year % 100 != 0: + elif (year % 400) == 0: return True - elif year % 400 != 0: + elif (year % 100) == 0: return False else: return True diff --git a/tests/test_catactivities.py b/tests/test_catactivities.py index e2051b1..ed29ae9 100644 --- a/tests/test_catactivities.py +++ b/tests/test_catactivities.py @@ -1,14 +1,17 @@ -# import pytest -# import time +import pytest +import time -# from catinabox import catactivities +from catinabox import catactivities def test__cat_nap__satisfying_nap(mocker): - # mock_sleep = mocker.patch.object(time, "sleep", autospec=True) - assert True + mock_sleep = mocker.patch.object(time, "sleep", autospec=True) + catactivities.cat_nap(500) + mock_sleep.assert_called_with(500) def test__cat_nap__not_satisfying(mocker): - # mock_sleep = mocker.patch.object(time, "sleep", autospec=True) - assert True + mock_sleep = mocker.patch.object(time, "sleep", autospec=True) + with pytest.raises(catactivities.NapWillNotBeSatisfying): + catactivities.cat_nap(299) + mock_sleep.assert_not_called() diff --git a/tests/test_catmath.py b/tests/test_catmath.py index ced6358..97befcd 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -2,18 +2,28 @@ def test__cat_years_to_hooman_years__middle_age__succeeds(): - assert True + expected = 50 + result = catmath.cat_years_to_hooman_years(10) + assert expected == result def test__cat_years_to_hooman_years__less_than_one_year__succeeds(): - assert True + expected = 2.5 + result = catmath.cat_years_to_hooman_years(0.5) + assert expected == result def test__cat_years_to_hooman_years__0__returns_0(): - assert True + expected = 0 + result = catmath.cat_years_to_hooman_years(0) + assert expected == result # BONUS MATERIAL FOR STEP 2 def test__is_cat_leap_year__succeeds(): + assert catmath.is_cat_leap_year(3) is False assert catmath.is_cat_leap_year(2016) is True + assert catmath.is_cat_leap_year(4) is True + assert catmath.is_cat_leap_year(100) is False + assert catmath.is_cat_leap_year(400) is True diff --git a/tests/test_cattery.py b/tests/test_cattery.py index b36692c..98f3f28 100644 --- a/tests/test_cattery.py +++ b/tests/test_cattery.py @@ -3,37 +3,38 @@ from catinabox import cattery +@pytest.fixture() +def cattery_client(): + return cattery.Cattery() + + ########################################################################### # add_cats ########################################################################### -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..878a7c3 100644 --- a/tests/test_safecatmath.py +++ b/tests/test_safecatmath.py @@ -1,6 +1,7 @@ # import pytest from catinabox import safecatmath +import pytest def test__cat_years_to_hooman_years__middle_age__succeeds(): @@ -19,17 +20,24 @@ 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(safecatmath.InvalidAge): + cat_age = -1 + assert safecatmath.cat_years_to_hooman_years(cat_age) def test__cat_years_to_hooman_years__older_than_1000__raises(): - assert True + with pytest.raises(safecatmath.InvalidAge): + cat_age = 1001 + assert safecatmath.cat_years_to_hooman_years(cat_age) def test__cat_years_to_hooman_years__string__raises(): - assert True + with pytest.raises(safecatmath.InvalidAge): + cat_age = 'one' + assert safecatmath.cat_years_to_hooman_years(cat_age) def test__cat_years_to_hooman_years__nan__raises(): - # hooman_age = float('nan') - assert True + with pytest.raises(safecatmath.InvalidAge): + cat_age = float('nan') + assert safecatmath.cat_years_to_hooman_years(cat_age)