From 462809144520f72929459c3d1fc6e350cd25bc7e Mon Sep 17 00:00:00 2001 From: Luyando Chitindi Date: Sun, 29 Dec 2024 20:18:34 +0200 Subject: [PATCH] Add test_is_positive.py from is-even branch --- solutions/tests/test_is_positive.py | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 solutions/tests/test_is_positive.py diff --git a/solutions/tests/test_is_positive.py b/solutions/tests/test_is_positive.py new file mode 100644 index 000000000..cadb586d0 --- /dev/null +++ b/solutions/tests/test_is_positive.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Unit tests for the is_positive function. + +@author: Luyando .E. Chitindi +""" + +import unittest +from solutions.is_positive import is_positive + + +class TestIsPositive(unittest.TestCase): + """Test the is_positive function""" + + def test_positive_number(self): + """It should evaluate 4 to True""" + actual = is_positive(4) + expected = True + self.assertEqual(actual, expected) + + def test_negative_number(self): + """It should evaluate -3 to False""" + actual = is_positive(-3) + expected = False + self.assertEqual(actual, expected) + + def test_zero(self): + """It should evaluate 0 to False""" + actual = is_positive(0) + expected = False + self.assertEqual(actual, expected) + + def test_non_integer_input(self): + """It should raise an assertion error if the argument is not an integer""" + with self.assertRaises(AssertionError): + is_positive(3.5) + + with self.assertRaises(AssertionError): + is_positive("string") + + +if __name__ == "__main__": + unittest.main()