From acc430eae77efc1e4de4f5e2476a976622a0df32 Mon Sep 17 00:00:00 2001 From: Muna Sattouf Date: Sun, 12 Jan 2025 17:00:53 +0200 Subject: [PATCH] updates --- solutions/binary_decimal_conversion.py | 3 ++- solutions/tests/test_binary_decimal_conversion.py | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/solutions/binary_decimal_conversion.py b/solutions/binary_decimal_conversion.py index 6e180d9a2..dc02b9f54 100644 --- a/solutions/binary_decimal_conversion.py +++ b/solutions/binary_decimal_conversion.py @@ -12,8 +12,9 @@ def decimal_to_binary(decimal: int) -> str: Example: DecimalToBinary('binary', 392) >>> 110001000 - + """ + if not isinstance(decimal, int): raise ValueError """ diff --git a/solutions/tests/test_binary_decimal_conversion.py b/solutions/tests/test_binary_decimal_conversion.py index 9224fb403..38f82732c 100644 --- a/solutions/tests/test_binary_decimal_conversion.py +++ b/solutions/tests/test_binary_decimal_conversion.py @@ -1,7 +1,6 @@ """ Module: test_binary_decimal_conversion contains test cases for the solution code. - Created by Muna Sattouf on January 2, 2024 Completed on January 2, 2024 """ @@ -16,7 +15,7 @@ def test_decimal_to_binary(self): def test_binary_to_decimal(self): """Should convert positive binary to decimal""" - self.assertEqual(binary_to_decimal(10011101), 157) + self.assertEqual(binary_to_decimal('10011101'), 157) def test_zero_decimal_to_binary(self): """should return 0""" @@ -40,7 +39,7 @@ def test_binarydecimalconversion_decimal(self): def test_binarydecimalconversion_binary(self): """Should convert decimal to binary when conversion type is binary""" - self.assertEqual(binary_decimal_conversion('binary', '392'), 110001000) + self.assertEqual(binary_decimal_conversion('binary', '392'), '110001000') def test_invalid_decimal_input(self): """Should raise ValueError for non-integer decimal input"""