From ccf0f10e3b6b5acc4c1789a9fb05684536c0a45f Mon Sep 17 00:00:00 2001 From: rowan08 Date: Sat, 2 Jun 2018 21:58:40 +0100 Subject: [PATCH 1/6] First pytest commit --- .pytest_cache/v/cache/lastfailed | 3 ++ .pytest_cache/v/cache/nodeids | 59 ++++++++++++++++++++++++++++++++ .pytest_cache/v/flakes/mtimes | 50 +++++++++++++++++++++++++++ .pytest_cache/v/mccabe/mtimes | 50 +++++++++++++++++++++++++++ .pytest_cache/v/pep8/mtimes | 50 +++++++++++++++++++++++++++ tests/test_catmath.py | 24 +++++++++++-- 6 files changed, 233 insertions(+), 3 deletions(-) create mode 100644 .pytest_cache/v/cache/lastfailed create mode 100644 .pytest_cache/v/cache/nodeids create mode 100644 .pytest_cache/v/flakes/mtimes create mode 100644 .pytest_cache/v/mccabe/mtimes create mode 100644 .pytest_cache/v/pep8/mtimes diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed new file mode 100644 index 0000000..b1086e3 --- /dev/null +++ b/.pytest_cache/v/cache/lastfailed @@ -0,0 +1,3 @@ +{ + "tests/test_catmath.py": true +} \ 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..73f0e50 --- /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": [ + 1527968854.1291442, + [] + ], + "catinabox/cattery.py": [ + 1527968854.1331818, + [] + ], + "catinabox/mccattery.py": [ + 1527968854.1371648, + [] + ], + "catinabox/safecatmath.py": [ + 1527968854.1412032, + [] + ], + "tests/test_catactivities.py": [ + 1527968854.423536, + [] + ], + "tests/test_catgenerator.py": [ + 1527968854.4336014, + [] + ], + "tests/test_catmath.py": [ + 1527972567.682441, + [] + ], + "tests/test_cattery.py": [ + 1527968854.548675, + [] + ], + "tests/test_safecatmath.py": [ + 1527968854.5587387, + [] + ] +} \ 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..040d79d --- /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": [ + 1527968854.1291442, + 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": [ + 1527968854.423536, + 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": [ + 1527972567.682441, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ + 1527968854.548675, + 7 + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ + 1527968854.5587387, + 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..bc52689 --- /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": [ + 1527968854.1291442, + [] + ], + "/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": [ + 1527968854.423536, + [] + ], + "/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": [ + 1527968854.443592, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ + 1527968854.548675, + [] + ], + "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ + 1527968854.5587387, + [] + ] +} \ No newline at end of file diff --git a/tests/test_catmath.py b/tests/test_catmath.py index ced6358..746d557 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -2,18 +2,36 @@ def test__cat_years_to_hooman_years__middle_age__succeeds(): - assert True + cat_years = 7 + hooman_years = catmath.cat_years_to_hooman_years(cat_years) + assert hooman_years == 35 def test__cat_years_to_hooman_years__less_than_one_year__succeeds(): - assert True + cat_years = 0.5 + hooman_years = catmath.cat_years_to_hooman_years(cat_years) + assert hooman_years == 2.5 def test__cat_years_to_hooman_years__0__returns_0(): - assert True + cat_years = 0 + hooman_years = catmath.cat_years_to_hooman_years(cat_years) + assert hooman_years == 0 # BONUS MATERIAL FOR STEP 2 def test__is_cat_leap_year__succeeds(): assert catmath.is_cat_leap_year(2016) is True + + +def test__is_cat_leap_year_2000__succeeds(): + assert catmath.is_cat_leap_year(2000) is True + + +def test__is_cat_leap_year_1900__fails(): + assert catmath.is_cat_leap_year(1900) is False + + +def test__is_cat_leap_year_2002__fails(): + assert catmath.is_cat_leap_year(2002) is False \ No newline at end of file From 23987aee69c5115bf9707de6a77a21fba5a7d97e Mon Sep 17 00:00:00 2001 From: rowan08 Date: Sat, 2 Jun 2018 22:17:23 +0100 Subject: [PATCH 2/6] Added EOF newline --- .pytest_cache/v/cache/lastfailed | 4 +--- .pytest_cache/v/flakes/mtimes | 4 ++-- .pytest_cache/v/mccabe/mtimes | 4 ++-- .pytest_cache/v/pep8/mtimes | 4 ++-- tests/test_catmath.py | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed index b1086e3..9e26dfe 100644 --- a/.pytest_cache/v/cache/lastfailed +++ b/.pytest_cache/v/cache/lastfailed @@ -1,3 +1 @@ -{ - "tests/test_catmath.py": true -} \ No newline at end of file +{} \ No newline at end of file diff --git a/.pytest_cache/v/flakes/mtimes b/.pytest_cache/v/flakes/mtimes index 73f0e50..950903f 100644 --- a/.pytest_cache/v/flakes/mtimes +++ b/.pytest_cache/v/flakes/mtimes @@ -12,7 +12,7 @@ [] ], "catinabox/catmath.py": [ - 1527968854.1291442, + 1527974091.0336118, [] ], "catinabox/cattery.py": [ @@ -36,7 +36,7 @@ [] ], "tests/test_catmath.py": [ - 1527972567.682441, + 1527974087.8107457, [] ], "tests/test_cattery.py": [ diff --git a/.pytest_cache/v/mccabe/mtimes b/.pytest_cache/v/mccabe/mtimes index 040d79d..fd50291 100644 --- a/.pytest_cache/v/mccabe/mtimes +++ b/.pytest_cache/v/mccabe/mtimes @@ -12,7 +12,7 @@ 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catmath.py": [ - 1527968854.1291442, + 1527974091.0336118, 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/cattery.py": [ @@ -36,7 +36,7 @@ 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catmath.py": [ - 1527972567.682441, + 1527974087.8107457, 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ diff --git a/.pytest_cache/v/pep8/mtimes b/.pytest_cache/v/pep8/mtimes index bc52689..0ff04b2 100644 --- a/.pytest_cache/v/pep8/mtimes +++ b/.pytest_cache/v/pep8/mtimes @@ -12,7 +12,7 @@ [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catmath.py": [ - 1527968854.1291442, + 1527974091.0336118, [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/cattery.py": [ @@ -36,7 +36,7 @@ [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catmath.py": [ - 1527968854.443592, + 1527974087.8107457, [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ diff --git a/tests/test_catmath.py b/tests/test_catmath.py index 746d557..f0d0277 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -34,4 +34,4 @@ def test__is_cat_leap_year_1900__fails(): def test__is_cat_leap_year_2002__fails(): - assert catmath.is_cat_leap_year(2002) is False \ No newline at end of file + assert catmath.is_cat_leap_year(2002) is False From 461121794fdf792169310706f38f75030196f93d Mon Sep 17 00:00:00 2001 From: Rowan Hatherley Date: Sun, 3 Jun 2018 11:56:53 +0100 Subject: [PATCH 3/6] safecatmath tests added --- .pytest_cache/v/flakes/mtimes | 2 +- .pytest_cache/v/mccabe/mtimes | 2 +- .pytest_cache/v/pep8/mtimes | 2 +- tests/test_safecatmath.py | 18 +++++++++++++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.pytest_cache/v/flakes/mtimes b/.pytest_cache/v/flakes/mtimes index 950903f..340b959 100644 --- a/.pytest_cache/v/flakes/mtimes +++ b/.pytest_cache/v/flakes/mtimes @@ -44,7 +44,7 @@ [] ], "tests/test_safecatmath.py": [ - 1527968854.5587387, + 1528023328.4403205, [] ] } \ No newline at end of file diff --git a/.pytest_cache/v/mccabe/mtimes b/.pytest_cache/v/mccabe/mtimes index fd50291..1c3d730 100644 --- a/.pytest_cache/v/mccabe/mtimes +++ b/.pytest_cache/v/mccabe/mtimes @@ -44,7 +44,7 @@ 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ - 1527968854.5587387, + 1528023328.4403205, 7 ] } \ No newline at end of file diff --git a/.pytest_cache/v/pep8/mtimes b/.pytest_cache/v/pep8/mtimes index 0ff04b2..76b54d5 100644 --- a/.pytest_cache/v/pep8/mtimes +++ b/.pytest_cache/v/pep8/mtimes @@ -44,7 +44,7 @@ [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ - 1527968854.5587387, + 1528023328.4403205, [] ] } \ No newline at end of file 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) From f14543d899b45c24700a911179c4a400aa3be42e Mon Sep 17 00:00:00 2001 From: Rowan Hatherley Date: Sun, 3 Jun 2018 14:19:08 +0100 Subject: [PATCH 4/6] Refactored cattery tests to use the pytest.fixture decorator --- .pytest_cache/v/flakes/mtimes | 2 +- .pytest_cache/v/mccabe/mtimes | 2 +- .pytest_cache/v/pep8/mtimes | 2 +- tests/test_cattery.py | 37 ++++++++++++++++++----------------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.pytest_cache/v/flakes/mtimes b/.pytest_cache/v/flakes/mtimes index 340b959..a1471dd 100644 --- a/.pytest_cache/v/flakes/mtimes +++ b/.pytest_cache/v/flakes/mtimes @@ -40,7 +40,7 @@ [] ], "tests/test_cattery.py": [ - 1527968854.548675, + 1528031199.9464488, [] ], "tests/test_safecatmath.py": [ diff --git a/.pytest_cache/v/mccabe/mtimes b/.pytest_cache/v/mccabe/mtimes index 1c3d730..4407132 100644 --- a/.pytest_cache/v/mccabe/mtimes +++ b/.pytest_cache/v/mccabe/mtimes @@ -40,7 +40,7 @@ 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ - 1527968854.548675, + 1528031199.9464488, 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ diff --git a/.pytest_cache/v/pep8/mtimes b/.pytest_cache/v/pep8/mtimes index 76b54d5..00b0e45 100644 --- a/.pytest_cache/v/pep8/mtimes +++ b/.pytest_cache/v/pep8/mtimes @@ -40,7 +40,7 @@ [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [ - 1527968854.548675, + 1528031199.9464488, [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [ 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") From b68360c53269de54b7affe0811eccf5e3640b4cd Mon Sep 17 00:00:00 2001 From: Rowan Hatherley Date: Sun, 3 Jun 2018 14:44:58 +0100 Subject: [PATCH 5/6] Added a mock test --- .pytest_cache/v/flakes/mtimes | 2 +- .pytest_cache/v/mccabe/mtimes | 2 +- .pytest_cache/v/pep8/mtimes | 2 +- tests/test_catactivities.py | 17 ++++++++++------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.pytest_cache/v/flakes/mtimes b/.pytest_cache/v/flakes/mtimes index a1471dd..0383884 100644 --- a/.pytest_cache/v/flakes/mtimes +++ b/.pytest_cache/v/flakes/mtimes @@ -28,7 +28,7 @@ [] ], "tests/test_catactivities.py": [ - 1527968854.423536, + 1528033436.5026548, [] ], "tests/test_catgenerator.py": [ diff --git a/.pytest_cache/v/mccabe/mtimes b/.pytest_cache/v/mccabe/mtimes index 4407132..0adcc41 100644 --- a/.pytest_cache/v/mccabe/mtimes +++ b/.pytest_cache/v/mccabe/mtimes @@ -28,7 +28,7 @@ 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catactivities.py": [ - 1527968854.423536, + 1528033436.5026548, 7 ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catgenerator.py": [ diff --git a/.pytest_cache/v/pep8/mtimes b/.pytest_cache/v/pep8/mtimes index 00b0e45..7787438 100644 --- a/.pytest_cache/v/pep8/mtimes +++ b/.pytest_cache/v/pep8/mtimes @@ -28,7 +28,7 @@ [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catactivities.py": [ - 1527968854.423536, + 1528033436.5026548, [] ], "/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catgenerator.py": [ 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() From 000b52cb7fd00d39ece5ab07fdf8dc7240abc1a4 Mon Sep 17 00:00:00 2001 From: Melanie Freshness Date: Thu, 23 May 2019 12:27:09 +0100 Subject: [PATCH 6/6] initial commit --- catinabox/catmath.py | 6 +++--- tests/test_catmath.py | 34 +++++++++++++--------------------- 2 files changed, 16 insertions(+), 24 deletions(-) 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_catmath.py b/tests/test_catmath.py index f0d0277..97befcd 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -2,36 +2,28 @@ def test__cat_years_to_hooman_years__middle_age__succeeds(): - cat_years = 7 - hooman_years = catmath.cat_years_to_hooman_years(cat_years) - assert hooman_years == 35 + 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(): - cat_years = 0.5 - hooman_years = catmath.cat_years_to_hooman_years(cat_years) - assert hooman_years == 2.5 + 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(): - cat_years = 0 - hooman_years = catmath.cat_years_to_hooman_years(cat_years) - assert hooman_years == 0 + 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 - - -def test__is_cat_leap_year_2000__succeeds(): - assert catmath.is_cat_leap_year(2000) is True - - -def test__is_cat_leap_year_1900__fails(): - assert catmath.is_cat_leap_year(1900) is False - - -def test__is_cat_leap_year_2002__fails(): - assert catmath.is_cat_leap_year(2002) is False + 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