From 06e34586914a9bcf842e13a3d9a27146b1542e7b Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:45:46 -0800 Subject: [PATCH] Update test_binary_to_string.py --- .../test_binary_to_string.py | 96 ++++++++++--------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py b/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py index 8bd7fdb5643..0a7e205c80c 100644 --- a/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py +++ b/kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py @@ -1,6 +1,5 @@ """ -Test for -> Binary to Text (ASCII) Conversion. - +Test for -> Binary to Text (ASCII) Conversion Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,7 +8,6 @@ import unittest import allure -from parameterized import parameterized from utils.log_func import print_log from kyu_6.binary_to_text_ascii_conversion.binary_to_string \ import binary_to_string @@ -31,55 +29,65 @@ url='https://www.codewars.com/kata/5583d268479559400d000064', name='Source/Kata') class SequenceTestCase(unittest.TestCase): - """Testing binary_to_string function.""" + """ + Testing binary_to_string function + """ - @parameterized.expand([ - ('0100100001100101011011000110110001101111', 'Hello'), - ('00110001001100000011000100110001', '1011'), - ('010100110111000001100001011100100110101101' - '110011001000000110011001101100011001010111' - '011100101110001011100010000001100101011011' - '010110111101110100011010010110111101101110' - '011100110010000001110010011000010110111000' - '100000011010000110100101100111011010000010' - '0001', 'Sparks flew.. emotions ran high!'), - ('001000010100000000100011001001000010010101' - '011110001001100010101000101000001010010101' - '000101010111010001010111001001110100011110' - '010101010101001001010011110100110001100100' - '011001100110011101100010011000100110100001' - '101110011011010100100101001011010000100100' - '101001001011010010000100100101010101010011' - '110010100000111111001111100011111100111100' - '011111100111111001111110011111100111111000' - '101001001010000010101000100110001001010101' - '111000111001001110000011011100110001001100' - '110010111100101101001011110010101000101101' - '0010101000101111', - '!@#$%^&*()QWErtyUIOLdfgbbhnmIKBJKHIUO' - '(?>?<~~~~~)(*&%^98713/-/*-*/'), - ('011001100111011101101111001100010110001101' - '101110001101100110011001101010011100010110' - '010101110001', 'fwo1cn6fjqeq')]) - def test_binary_to_string(self, binary, expected): + def test_binary_to_string(self): """ - Testing 'binary_to_string' function with various test data. - + Testing binary_to_string function + with various test data :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing binary_to_string function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( - "

Codewars badge:

" - "" - "

Test Description:

" + '

Codewars badge:

' + '' + '

Test Description:

' "

Test a function that takes in a binary string and returns " "the equivalent decoded text (the text is ASCII encoded).

") # pylint: enable-msg=R0801 - actual_result = binary_to_string(binary) - with allure.step(f"Enter a binary ({binary}) and verify the " - f"expected output ({expected}) vs " - f"actual result ({actual_result})"): - print_log(binary=binary, expected=expected, result=actual_result) - self.assertEqual(expected, actual_result) + test_data: tuple = ( + ('0100100001100101011011000110110001101111', 'Hello'), + ('00110001001100000011000100110001', '1011'), + ('010100110111000001100001011100100110101101' + '110011001000000110011001101100011001010111' + '011100101110001011100010000001100101011011' + '010110111101110100011010010110111101101110' + '011100110010000001110010011000010110111000' + '100000011010000110100101100111011010000010' + '0001', 'Sparks flew.. emotions ran high!'), + ('001000010100000000100011001001000010010101' + '011110001001100010101000101000001010010101' + '000101010111010001010111001001110100011110' + '010101010101001001010011110100110001100100' + '011001100110011101100010011000100110100001' + '101110011011010100100101001011010000100100' + '101001001011010010000100100101010101010011' + '110010100000111111001111100011111100111100' + '011111100111111001111110011111100111111000' + '101001001010000010101000100110001001010101' + '111000111001001110000011011100110001001100' + '110010111100101101001011110010101000101101' + '0010101000101111', + '!@#$%^&*()QWErtyUIOLdfgbbhnmIKBJKHIUO' + '(?>?<~~~~~)(*&%^98713/-/*-*/'), + ('011001100111011101101111001100010110001101' + '101110001101100110011001101010011100010110' + '010101110001', 'fwo1cn6fjqeq')) + + for binary, expected in test_data: + actual_result = binary_to_string(binary) + with allure.step(f"Enter a binary ({binary}) and verify the " + f"expected output ({expected}) vs " + f"actual result ({actual_result})"): + + print_log(binary=binary, + expected=expected, + result=actual_result) + + self.assertEqual(expected, + actual_result)