From be0214bf841c70699826f0558fd9b235e3d09546 Mon Sep 17 00:00:00 2001 From: "Kurt R. Lindberg" <85883737+kurtlindberg@users.noreply.github.com> Date: Fri, 30 May 2025 10:08:27 -0700 Subject: [PATCH 1/2] Add longer sleep(duration) test --- pyCatSim/tests/test_api_Cat.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 + ] From d1fb6b5566315f87cd7dd35e38aa7cda67897ec2 Mon Sep 17 00:00:00 2001 From: "Kurt R. Lindberg" <85883737+kurtlindberg@users.noreply.github.com> Date: Fri, 30 May 2025 10:10:15 -0700 Subject: [PATCH 2/2] sleep(duration) now required arg --- pyCatSim/api/cat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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