From d82c8ba3e3bbe4237e008bf22b0f1b3ee52e1439 Mon Sep 17 00:00:00 2001 From: Moealfadil <142026026+Moealfadil@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:43:56 +0200 Subject: [PATCH 1/2] CI checks --- solutions/IsPrime.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/solutions/IsPrime.py b/solutions/IsPrime.py index a943faff5..656de9cfd 100644 --- a/solutions/IsPrime.py +++ b/solutions/IsPrime.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -A module for finding if an integer is prime. +Module for finding if an integer is prime. Module contents: - IsPrime: finds if an integer is prime. @@ -30,6 +30,8 @@ def IsPrime(a: int) -> str: prime >>> IsPrime(2.5) invalid input + >>> IsPrime(-1) + not prime """ if not isinstance(a, int): return "invalid input" From 1da973fb4bc054996da444a2364e13b57683e543 Mon Sep 17 00:00:00 2001 From: Moealfadil <142026026+Moealfadil@users.noreply.github.com> Date: Sun, 12 Jan 2025 13:55:41 +0200 Subject: [PATCH 2/2] change file name --- solutions/{IsPrime.py => is_prime.py} | 18 +++++++------- .../{test_IsPrime.py => test_is_prime.py} | 24 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) rename solutions/{IsPrime.py => is_prime.py} (74%) rename solutions/tests/{test_IsPrime.py => test_is_prime.py} (79%) diff --git a/solutions/IsPrime.py b/solutions/is_prime.py similarity index 74% rename from solutions/IsPrime.py rename to solutions/is_prime.py index 656de9cfd..ddb48720f 100644 --- a/solutions/IsPrime.py +++ b/solutions/is_prime.py @@ -4,33 +4,33 @@ Module for finding if an integer is prime. Module contents: - - IsPrime: finds if an integer is prime. + - is_prime: finds if an integer is prime. Created on XX XX XX @author: Mohammed Elfadil """ -def IsPrime(a: int) -> str: +def is_prime(a: int) -> str: """Checks if an integer is prime. Parameter: a: int Return -> str: whether a is prime or not Raises: AssertionError: if the argument is not an integer - >>> IsPrime(0) + >>> is_prime(0) not prime - >>> IsPrime(1) + >>> is_prime(1) not prime - >>> IsPrime(2) + >>> is_prime(2) prime - >>> IsPrime(4) + >>> is_prime(4) not prime - >>> IsPrime(7) + >>> is_prime(7) prime - >>> IsPrime(2.5) + >>> is_prime(2.5) invalid input - >>> IsPrime(-1) + >>> is_prime(-1) not prime """ if not isinstance(a, int): diff --git a/solutions/tests/test_IsPrime.py b/solutions/tests/test_is_prime.py similarity index 79% rename from solutions/tests/test_IsPrime.py rename to solutions/tests/test_is_prime.py index 399160f98..4364f8a89 100644 --- a/solutions/tests/test_IsPrime.py +++ b/solutions/tests/test_is_prime.py @@ -1,67 +1,67 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import unittest -from solutions.IsPrime import IsPrime +from solutions.is_prime import is_prime class TestIsPrime(unittest.TestCase): - """test the IsPrime function""" + """test the is_prime function""" def test_0(self): """It should evaluate not prime""" - actual = IsPrime(0) + actual = is_prime(0) expected = "not prime" self.assertEqual(actual, expected) def test_1(self): """It should evaluate not prime""" - actual = IsPrime(1) + actual = is_prime(1) expected = "not prime" self.assertEqual(actual, expected) def test_2(self): - actual = IsPrime(2) + actual = is_prime(2) expected = "prime" self.assertEqual(actual, expected) def test_4(self): """its should evaluate not prime""" - actual = IsPrime(4) + actual = is_prime(4) expected = "not prime" self.assertEqual(actual, expected) def test_7(self): """It should evaluate prime""" - actual = IsPrime(7) + actual = is_prime(7) expected = "prime" self.assertEqual(actual, expected) def test_9(self): """It should evaluate not prime""" - actual = IsPrime(9) + actual = is_prime(9) expected = "not prime" self.assertEqual(actual, expected) def test_11(self): """It should evaluate prime""" - actual = IsPrime(11) + actual = is_prime(11) expected = "prime" self.assertEqual(actual, expected) def test_13(self): """It should evaluate prime""" - actual = IsPrime(13) + actual = is_prime(13) expected = "prime" self.assertEqual(actual, expected) def test_negative(self): """It should evaluate not prime""" - actual = IsPrime(-1) + actual = is_prime(-1) expected = "not prime" self.assertEqual(actual, expected) def test_not_integer(self): """It should evaluate not prime""" - actual = IsPrime(1.5) + actual = is_prime(1.5) expected = "invalid input" self.assertEqual(actual, expected)