From 21c9c15ffd646a9ca8650e249e7847b9ad01dccf Mon Sep 17 00:00:00 2001 From: melatend Date: Thu, 9 Jan 2025 15:51:56 -0600 Subject: [PATCH 01/12] Added code and unittest for get_prime_numbers function --- solutions/get_prime_numbers.py | 46 +++++++++++++++++++++++ solutions/tests/test_get_prime_numbers.py | 34 +++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 solutions/get_prime_numbers.py create mode 100644 solutions/tests/test_get_prime_numbers.py diff --git a/solutions/get_prime_numbers.py b/solutions/get_prime_numbers.py new file mode 100644 index 000000000..371a4f939 --- /dev/null +++ b/solutions/get_prime_numbers.py @@ -0,0 +1,46 @@ +# prime_numbers.py + +""" +This module provides a function to find all prime numbers up to a given integer. + +Function: + - get_prime_numbers: Returns a list of prime numbers less than or equal to a given integer. +""" + +from typing import List + + +def get_prime_numbers(n: int) -> List[int]: + """ + Returns a list of all prime numbers less than or equal to the given integer. + + Parameters: + n (int): The upper limit integer to find prime numbers up to. + + Returns: + List[int]: A list of prime numbers less than or equal to n. + + Raises: + ValueError: If n is less than 2. + + Examples: + >>> get_prime_numbers(10) + [2, 3, 5, 7] + >>> get_prime_numbers(2) + [2] + >>> get_prime_numbers(1) + [] + """ + if n < 2: + return [] + + primes = [] + for num in range(2, n + 1): + is_prime = True + for i in range(2, int(num**0.5) + 1): + if num % i == 0: + is_prime = False + break + if is_prime: + primes.append(num) + return primes diff --git a/solutions/tests/test_get_prime_numbers.py b/solutions/tests/test_get_prime_numbers.py new file mode 100644 index 000000000..9b781e917 --- /dev/null +++ b/solutions/tests/test_get_prime_numbers.py @@ -0,0 +1,34 @@ +# tests/test_prime_numbers.py + +""" +Unit tests for the get_prime_numbers function. +""" + +import unittest +from solutions.get_prime_numbers import get_prime_numbers + + +class TestGetPrimeNumbers(unittest.TestCase): + """Test cases for the get_prime_numbers function.""" + + def test_primes_up_to_10(self): + """Test that the function returns correct primes up to 10.""" + self.assertEqual(get_prime_numbers(10), [2, 3, 5, 7]) + + def test_primes_up_to_2(self): + """Test that the function returns correct primes up to 2.""" + self.assertEqual(get_prime_numbers(2), [2]) + + def test_no_primes_below_2(self): + """Test that the function returns an empty list for n < 2.""" + self.assertEqual(get_prime_numbers(1), []) + self.assertEqual(get_prime_numbers(0), []) + self.assertEqual(get_prime_numbers(-5), []) + + def test_large_number(self): + """Test the function with a larger number.""" + self.assertEqual(get_prime_numbers(20), [2, 3, 5, 7, 11, 13, 17, 19]) + + +if __name__ == "__main__": + unittest.main() From 5f344c0f92fc2a000a9616a6498a88903342d70b Mon Sep 17 00:00:00 2001 From: melatend Date: Thu, 9 Jan 2025 16:16:41 -0600 Subject: [PATCH 02/12] Updated the files for missing some rules --- solutions/get_prime_numbers.py | 2 ++ solutions/tests/test_get_prime_numbers.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/solutions/get_prime_numbers.py b/solutions/get_prime_numbers.py index 371a4f939..963b658fb 100644 --- a/solutions/get_prime_numbers.py +++ b/solutions/get_prime_numbers.py @@ -5,6 +5,8 @@ Function: - get_prime_numbers: Returns a list of prime numbers less than or equal to a given integer. +Created on: January 6, 2025 +@author: Melat Assefa """ from typing import List diff --git a/solutions/tests/test_get_prime_numbers.py b/solutions/tests/test_get_prime_numbers.py index 9b781e917..3dc6a5fa1 100644 --- a/solutions/tests/test_get_prime_numbers.py +++ b/solutions/tests/test_get_prime_numbers.py @@ -2,6 +2,8 @@ """ Unit tests for the get_prime_numbers function. +Created on: January 6, 2025 +@author: Melat Assefa """ import unittest From 6fcedf4a0e7a16243d6c80a5fff6f83aab9b5b14 Mon Sep 17 00:00:00 2001 From: MUSABKAYMAK Date: Fri, 10 Jan 2025 15:41:37 -0600 Subject: [PATCH 03/12] added find_highest_alpha_position --- solutions/find_highest_alpha_position.py | 51 ++++++++++++++++ .../tests/test_find_highest_alpha_position.py | 59 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 solutions/find_highest_alpha_position.py create mode 100644 solutions/tests/test_find_highest_alpha_position.py diff --git a/solutions/find_highest_alpha_position.py b/solutions/find_highest_alpha_position.py new file mode 100644 index 000000000..f0147f17d --- /dev/null +++ b/solutions/find_highest_alpha_position.py @@ -0,0 +1,51 @@ +"""Module for finding the highest alphabetical position in a text string. + +This module provides functionality to find the alphabetical position (1-26) +of the character that appears latest in the alphabet within a given text. + +@author: Musab Kaymak +@created: 01/09/2025 +""" + +def find_highest_alpha_position(text: str) -> int: + """Find the alphabetical position of the latest alphabet character in text. + + Parameters: + text (str): The input text to analyze. Must contain at least one letter + and only contain English letters. Numbers and special characters are ignored. + + Returns: + int: The highest alphabetical position (1-26) found in the text. + 'a' is position 1, 'z' is position 26. + + Raises: + ValueError: If the text is empty or contains no letters. + ValueError: If the text contains non-ASCII letters. + + Examples: + >>> find_highest_alpha_position("flower") + 23 + >>> find_highest_alpha_position("apple") + 16 + >>> find_highest_alpha_position("ZEBRA") + 26 + """ + if not text: + raise ValueError("Input text cannot be empty") + + if not any(c.isalpha() for c in text): + raise ValueError("Input text must contain at least one letter") + + if not all(c.isascii() for c in text): + raise ValueError("Input text must contain only English characters") + + alphabet = "abcdefghijklmnopqrstuvwxyz" + max_position = 0 + + for char in text.lower(): + if char.isalpha(): + position = alphabet.index(char.lower()) + 1 + if position > max_position: + max_position = position + + return max_position diff --git a/solutions/tests/test_find_highest_alpha_position.py b/solutions/tests/test_find_highest_alpha_position.py new file mode 100644 index 000000000..d95ab8ef6 --- /dev/null +++ b/solutions/tests/test_find_highest_alpha_position.py @@ -0,0 +1,59 @@ +"""Tests for the find_highest_alpha_position function. + +@author: Musab Kaymak +@created: 01/09/2025 +""" + +import unittest +from solutions.find_highest_alpha_position import find_highest_alpha_position + + +class TestFindHighestAlphaPosition(unittest.TestCase): + """Test cases for the find_highest_alpha_position function.""" + + def test_simple_word(self): + """Test with a simple lowercase word.""" + self.assertEqual(find_highest_alpha_position("flower"), 23) + + def test_uppercase_word(self): + """Test with an uppercase word.""" + self.assertEqual(find_highest_alpha_position("ZEBRA"), 26) + + def test_mixed_case_word(self): + """Test with a mixed case word.""" + self.assertEqual(find_highest_alpha_position("PyThOn"), 25) + + def test_single_letter(self): + """Test with a single letter.""" + self.assertEqual(find_highest_alpha_position("a"), 1) + + def test_with_spaces(self): + """Test with text containing spaces.""" + self.assertEqual(find_highest_alpha_position("hello world"), 23) + + def test_with_numbers(self): + """Test with text containing numbers.""" + self.assertEqual(find_highest_alpha_position("hello123"), 15) + + def test_with_special_characters(self): + """Test with text containing special characters.""" + self.assertEqual(find_highest_alpha_position("hello!@#"), 15) + + def test_empty_string(self): + """Test that empty string raises ValueError.""" + with self.assertRaises(ValueError, msg="Input text cannot be empty"): + find_highest_alpha_position("") + + def test_no_letters(self): + """Test that string with no letters raises ValueError.""" + with self.assertRaises( + ValueError, msg="Input text must contain at least one letter." + ): + find_highest_alpha_position("123") + + def test_non_english_characters(self): + """Test that non-English characters raise ValueError.""" + with self.assertRaises( + ValueError, msg="Input text must contain only English characters." + ): + find_highest_alpha_position("héllo") From 29c3f310279371ba8cd34b6b3913bb8048c4c569 Mon Sep 17 00:00:00 2001 From: MUSABKAYMAK Date: Fri, 10 Jan 2025 15:45:55 -0600 Subject: [PATCH 04/12] added find_highest_alpha_position --- solutions/find_highest_alpha_position.py | 19 ++++++++++--------- .../tests/test_find_highest_alpha_position.py | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/solutions/find_highest_alpha_position.py b/solutions/find_highest_alpha_position.py index f0147f17d..c03ce0617 100644 --- a/solutions/find_highest_alpha_position.py +++ b/solutions/find_highest_alpha_position.py @@ -7,21 +7,22 @@ @created: 01/09/2025 """ + def find_highest_alpha_position(text: str) -> int: """Find the alphabetical position of the latest alphabet character in text. - + Parameters: text (str): The input text to analyze. Must contain at least one letter and only contain English letters. Numbers and special characters are ignored. - + Returns: int: The highest alphabetical position (1-26) found in the text. 'a' is position 1, 'z' is position 26. - + Raises: ValueError: If the text is empty or contains no letters. ValueError: If the text contains non-ASCII letters. - + Examples: >>> find_highest_alpha_position("flower") 23 @@ -32,20 +33,20 @@ def find_highest_alpha_position(text: str) -> int: """ if not text: raise ValueError("Input text cannot be empty") - + if not any(c.isalpha() for c in text): raise ValueError("Input text must contain at least one letter") - + if not all(c.isascii() for c in text): raise ValueError("Input text must contain only English characters") - + alphabet = "abcdefghijklmnopqrstuvwxyz" max_position = 0 - + for char in text.lower(): if char.isalpha(): position = alphabet.index(char.lower()) + 1 if position > max_position: max_position = position - + return max_position diff --git a/solutions/tests/test_find_highest_alpha_position.py b/solutions/tests/test_find_highest_alpha_position.py index d95ab8ef6..051185ba7 100644 --- a/solutions/tests/test_find_highest_alpha_position.py +++ b/solutions/tests/test_find_highest_alpha_position.py @@ -5,6 +5,7 @@ """ import unittest + from solutions.find_highest_alpha_position import find_highest_alpha_position From 0f73e711342bf5a4ecf427f463e1b6119a7e9503 Mon Sep 17 00:00:00 2001 From: melatend Date: Sat, 11 Jan 2025 11:02:03 -0600 Subject: [PATCH 05/12] Updated and revised the files as suggested on the review --- solutions/get_prime_numbers.py | 3 +++ solutions/tests/test_get_prime_numbers.py | 33 +++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/solutions/get_prime_numbers.py b/solutions/get_prime_numbers.py index 963b658fb..cb2820dc4 100644 --- a/solutions/get_prime_numbers.py +++ b/solutions/get_prime_numbers.py @@ -24,6 +24,7 @@ def get_prime_numbers(n: int) -> List[int]: Raises: ValueError: If n is less than 2. + TypeError: If n is not an integer. Examples: >>> get_prime_numbers(10) @@ -33,6 +34,8 @@ def get_prime_numbers(n: int) -> List[int]: >>> get_prime_numbers(1) [] """ + if not isinstance(n, int): + raise TypeError("Input must be an integer.") if n < 2: return [] diff --git a/solutions/tests/test_get_prime_numbers.py b/solutions/tests/test_get_prime_numbers.py index 3dc6a5fa1..aa29f1ce9 100644 --- a/solutions/tests/test_get_prime_numbers.py +++ b/solutions/tests/test_get_prime_numbers.py @@ -2,6 +2,11 @@ """ Unit tests for the get_prime_numbers function. +This test suite includes: +- Regular cases: Typical inputs that the function is expected to handle. +- Edge cases: Inputs that are at the boundary of what the function should handle. +- Error cases: Inputs that should raise exceptions due to invalid input. + Created on: January 6, 2025 @author: Melat Assefa """ @@ -13,24 +18,42 @@ class TestGetPrimeNumbers(unittest.TestCase): """Test cases for the get_prime_numbers function.""" + # Regular Cases def test_primes_up_to_10(self): - """Test that the function returns correct primes up to 10.""" + """Regular case: Test that the function returns correct primes up to 10.""" self.assertEqual(get_prime_numbers(10), [2, 3, 5, 7]) def test_primes_up_to_2(self): - """Test that the function returns correct primes up to 2.""" + """Regular case: Test that the function returns correct primes up to 2.""" self.assertEqual(get_prime_numbers(2), [2]) - def test_no_primes_below_2(self): - """Test that the function returns an empty list for n < 2.""" + # Edge Cases + def test_no_primes_below_2_for_1(self): + """Edge case: Test that the function returns an empty list for n = 1.""" self.assertEqual(get_prime_numbers(1), []) + + def test_no_primes_below_2_for_0(self): + """Edge case: Test that the function returns an empty list for n = 0.""" self.assertEqual(get_prime_numbers(0), []) + + def test_no_primes_below_2_for_negative(self): + """Edge case: Test that the function returns an empty list for negative n.""" self.assertEqual(get_prime_numbers(-5), []) def test_large_number(self): - """Test the function with a larger number.""" + """Edge case: Test the function with a larger number.""" self.assertEqual(get_prime_numbers(20), [2, 3, 5, 7, 11, 13, 17, 19]) + # Error Cases + def test_non_integer_input_raises_type_error(self): + """Error case: Test that the function raises a TypeError for non-integer input.""" + with self.assertRaises(TypeError): + get_prime_numbers("ten") + with self.assertRaises(TypeError): + get_prime_numbers(5.5) + with self.assertRaises(TypeError): + get_prime_numbers(None) + if __name__ == "__main__": unittest.main() From b80689660b45361d94520c5e9e5d37f661314744 Mon Sep 17 00:00:00 2001 From: Melat-arch Date: Sat, 11 Jan 2025 15:28:49 -0600 Subject: [PATCH 06/12] did some formatting --- solutions/tests/test_get_prime_numbers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/tests/test_get_prime_numbers.py b/solutions/tests/test_get_prime_numbers.py index aa29f1ce9..d4f67a400 100644 --- a/solutions/tests/test_get_prime_numbers.py +++ b/solutions/tests/test_get_prime_numbers.py @@ -5,7 +5,7 @@ This test suite includes: - Regular cases: Typical inputs that the function is expected to handle. - Edge cases: Inputs that are at the boundary of what the function should handle. -- Error cases: Inputs that should raise exceptions due to invalid input. +- Error cases: Inputs that should raise exception due to invalid input. Created on: January 6, 2025 @author: Melat Assefa From 85bb9f1ea98a11d08e49b86c8365f2ae7133a589 Mon Sep 17 00:00:00 2001 From: Vahablotfi Date: Sat, 11 Jan 2025 20:13:14 -0700 Subject: [PATCH 07/12] check_if_coprime solution added --- solutions/check_coprime.py | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 solutions/check_coprime.py diff --git a/solutions/check_coprime.py b/solutions/check_coprime.py new file mode 100644 index 000000000..30e8614ae --- /dev/null +++ b/solutions/check_coprime.py @@ -0,0 +1,53 @@ +"""Module to check if two numbers are relatively prime. + +This module defines a function to determine whether two numbers (Integer) are relatively +prime, meaning they have no common factors than 1. + +@author: Vahab +@Created: 11/01/2025 +""" + + +def check_coprime(first_integer: int, second_integer: int) -> bool: + """Check if two numbers are relatively prime. + + Two numbers are relatively prime when there + are no common factors other than 1 + + Parameters: + first_integer (int): The first number (must be a positive integer). + second_integer (int): The second number (must be a positive integer). + + + Returns: + bool: True if the numbers are relatively prime, False otherwise. + + Raises: + ValueError: If either of the inputs is not a positive integer. + TypeError: If either of the inputs is not an integer. + + >>> check_coprime(15, 28) + True + >>> check_coprime(8, 12) + False + >>> check_coprime(7, 9) + True + """ + + # Check if inputs are integers + if not isinstance(first_integer, int) or not isinstance(second_integer, int): + raise TypeError("Both inputs must be integers.") + + # Check if inputs are positive integers + if first_integer <= 0 or second_integer <= 0: + raise ValueError("Both numbers must be positive integers.") + + # Find the smaller of the two numbers + smaller = min(first_integer, second_integer) + + # Check for any common factors greater than 1 + for i in range(2, smaller + 1): + if first_integer % i == 0 and second_integer % i == 0: + return False + + return True From 6058f756255e7b60caa7c464119aa98646b91b80 Mon Sep 17 00:00:00 2001 From: Vahablotfi Date: Sat, 11 Jan 2025 20:37:00 -0700 Subject: [PATCH 08/12] unit test for check_coprime added --- solutions/tests/test_check_coprime.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 solutions/tests/test_check_coprime.py diff --git a/solutions/tests/test_check_coprime.py b/solutions/tests/test_check_coprime.py new file mode 100644 index 000000000..58bd1dcbe --- /dev/null +++ b/solutions/tests/test_check_coprime.py @@ -0,0 +1,9 @@ +"""Tests for check_coprime function. + + +This module contains unit tests to ensure the check_coprime function works as expected, +including handling edge cases and defensive assertions. + +@author: Vahab +@created: 11/01/2025 +""" From a5bf8cbb3b24876005dc88c095aae493f2caf6a0 Mon Sep 17 00:00:00 2001 From: Vahablotfi Date: Sat, 11 Jan 2025 21:10:17 -0700 Subject: [PATCH 09/12] unit test for check_coprime completed --- solutions/tests/test_check_coprime.py | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/solutions/tests/test_check_coprime.py b/solutions/tests/test_check_coprime.py index 58bd1dcbe..6269710db 100644 --- a/solutions/tests/test_check_coprime.py +++ b/solutions/tests/test_check_coprime.py @@ -7,3 +7,47 @@ @author: Vahab @created: 11/01/2025 """ + +import unittest + + +from check_coprime import check_coprime + + +class TestCoprimeFunction(unittest.TestCase): + """Test cases for the check_coprime function.""" + + def test_coprime_true(self): + """Test case where the numbers are relatively prime.""" + self.assertTrue(check_coprime(15, 28)) + + def test_coprime_false(self): + """Test case where the numbers are not relatively prime.""" + self.assertFalse(check_coprime(8, 12)) + + def test_coprime_same_value(self): + """Test case where both numbers are the same and greater than 1.""" + self.assertFalse(check_coprime(12, 12)) + + def test_coprime_negative_input(self): + """Test case where negative numbers are provided.""" + with self.assertRaises(ValueError): + check_coprime(-5, 28) + + def test_coprime_non_integer_input(self): + """Test case where non-integer inputs are provided.""" + with self.assertRaises(TypeError): + check_coprime("15", 28) + + def test_coprime_large_numbers(self): + """Test case with large numbers to check performance.""" + self.assertTrue(check_coprime(1, 100)) + + def test_coprime_edge_case(self): + """Test case where one input is 0.""" + with self.assertRaises(ValueError): + check_coprime(0, 10) + + +if __name__ == "__main__": + unittest.main() From c6260175b94ff0485fbb9f4602fce65b93d5d813 Mon Sep 17 00:00:00 2001 From: Vahablotfi Date: Sat, 11 Jan 2025 21:40:20 -0700 Subject: [PATCH 10/12] fix import module in unit test file --- solutions/tests/test_check_coprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/tests/test_check_coprime.py b/solutions/tests/test_check_coprime.py index 6269710db..0cd2afef5 100644 --- a/solutions/tests/test_check_coprime.py +++ b/solutions/tests/test_check_coprime.py @@ -11,7 +11,7 @@ import unittest -from check_coprime import check_coprime +from solutions.check_coprime import check_coprime class TestCoprimeFunction(unittest.TestCase): From cad061bfd5c604c1f3ee24ce344b04f9dbdf00c4 Mon Sep 17 00:00:00 2001 From: Vahablotfi Date: Sun, 12 Jan 2025 00:17:38 -0700 Subject: [PATCH 11/12] get_even_numbers solution file added --- solutions/get_even_numbers.py | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 solutions/get_even_numbers.py diff --git a/solutions/get_even_numbers.py b/solutions/get_even_numbers.py new file mode 100644 index 000000000..123f15b51 --- /dev/null +++ b/solutions/get_even_numbers.py @@ -0,0 +1,49 @@ +""" +Module for filtering even numbers from a list of integers. + +This module provides a function that takes a list of integers as input +and returns a list of all even numbers from the input list. + +@author: Vahab +@created: 01/11/2025 +""" + +from typing import List + + +def get_even_numbers(numbers: List[int]) -> List[int]: + """ + Filters even numbers from a list of integers. + + Parameters: + numbers (List[int]): A list of integers to filter. + + Returns: + List[int]: A list containing all even numbers from the input list. + + Raises: + TypeError: If the input is not a list or contains non-integer elements. + + Example: + >>> get_even_numbers([1, 2, 3, 4, 5, 6]) + [2, 4, 6] + >>> get_even_numbers([1, 3, 5]) + [] + >>> get_even_numbers([]) + [] + """ + # Check the input is a list + if not isinstance(numbers, list): + raise TypeError("Input must be a list.") + + # Check the list items are only integers + if not all(isinstance(n, int) for n in numbers): + raise TypeError("All elements in the list must be integers.") + + # Filters the even number from input list and store them in a list + return [n for n in numbers if n % 2 == 0] + + +if __name__ == "__main__": + example_input = [1, 2, 3, 4, 5, 6] + print(get_even_numbers(example_input)) From afecb58268e8d5a421c74441a6618b565e8d6987 Mon Sep 17 00:00:00 2001 From: Vahablotfi Date: Sun, 12 Jan 2025 00:27:58 -0700 Subject: [PATCH 12/12] unit test for get_even_numbers added --- solutions/tests/test_get_even_numbers.py | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 solutions/tests/test_get_even_numbers.py diff --git a/solutions/tests/test_get_even_numbers.py b/solutions/tests/test_get_even_numbers.py new file mode 100644 index 000000000..a2ffde8fd --- /dev/null +++ b/solutions/tests/test_get_even_numbers.py @@ -0,0 +1,64 @@ +""" +Unit tests for get_even_numbers function. + +@created: 01/11/2025 +@author: Vahab +""" + +import unittest + +from solutions.get_even_numbers import get_even_numbers + + +class TestGetEvenNumbers(unittest.TestCase): + """ + Tests for the get_even_numbers function. + """ + + def test_basic_functionality(self): + """ + Test: Check if the function returns the correct even numbers from a list. + """ + self.assertEqual(get_even_numbers([1, 2, 3, 4, 5, 6]), [2, 4, 6]) + + def test_no_even_numbers(self): + """ + Test: Check if the function returns an empty list when no even numbers are present. + """ + self.assertEqual(get_even_numbers([1, 3, 5]), []) + + def test_empty_list(self): + """ + Test: Check if the function handles an empty list correctly. + """ + self.assertEqual(get_even_numbers([]), []) + + def test_negative_numbers(self): + """ + Test: Check if the function correctly identifies even negative numbers. + """ + self.assertEqual(get_even_numbers([-1, -2, -3, -4]), [-2, -4]) + + def test_large_numbers(self): + """ + Test: Check if the function handles large numbers correctly. + """ + self.assertEqual(get_even_numbers([10**6, 10**9 + 1]), [10**6]) + + def test_invalid_input_not_list(self): + """ + Test: Check if the function raises a TypeError for non-list inputs. + """ + with self.assertRaises(TypeError): + get_even_numbers("not a list") + + def test_invalid_input_non_integer_elements(self): + """ + Test: Check if the function raises a TypeError for lists with non-integer elements. + """ + with self.assertRaises(TypeError): + get_even_numbers([1, 2, "three", 4]) + + +if __name__ == "__main__": + unittest.main()