diff --git a/pyCatSim/api/cat.py b/pyCatSim/api/cat.py index 404044a..7e78664 100644 --- a/pyCatSim/api/cat.py +++ b/pyCatSim/api/cat.py @@ -329,7 +329,7 @@ def eat(self): return {"hunger_level": self.hunger_level, "mood": self.mood} - def sleep(self, duration=0): + def sleep(self, duration): """ Simulates the cat getting some sleep. @@ -340,7 +340,7 @@ def sleep(self, duration=0): Parameters ---------- - duration : int or float, optional + duration : int or float Number of hours the cat sleeps. Must be an integer or float. The default is 0. Raises diff --git a/pyCatSim/tests/test_api_Cat.py b/pyCatSim/tests/test_api_Cat.py index a5b949e..f5d8d3b 100644 --- a/pyCatSim/tests/test_api_Cat.py +++ b/pyCatSim/tests/test_api_Cat.py @@ -162,19 +162,21 @@ class TestcatCatSleep: [ (0), (1), - (4.4), + (14.4), pytest.param("kitty", marks=pytest.mark.xfail), pytest.param(-1, marks=pytest.mark.xfail), pytest.param(17, marks=pytest.mark.xfail) ] ) def test_sleep_t0(self, duration): - cat = Cat(name="Boots", color="tabby") + cat = Cat(name="Boots", color="tabby", energy=0) cat.sleep(duration) if duration < 3: assert cat.energy == 0 + if ((duration >= 12) and (duration < 15)): + assert cat.energy == 4 class TestcatCatFact: @@ -197,4 +199,4 @@ def test_give_fact_t0(self): "Cats use their whiskers to detect changes in their surroundings.", "The average house cat can run at speeds up to 30 mph.", "Cats meow only to communicate with humans." - ] \ No newline at end of file + ]