def test_filebinarysearch(): input1 = ['abhi', 'janis', 'jettus', 'noothan', 'sreeraj', 'thanzeeh'] input2 = "jettus" result = binary(input1, input2) expected = 2 assert result == expected
def test_filebinaryseachlistinteger(): result = binary(json_string['filebinarysearch'][4]['input1'], json_string['filebinarysearch'][4]['input2']) expected = json_string['filebinarysearch'][4]['output'] assert result == expected
def test_filebinaryseachspecial(): result = binary(json_string['filebinarysearch'][2]['input1'], json_string['filebinarysearch'][2]['input2']) expected = json_string['filebinarysearch'][2]['output'] assert result == expected
def test_filebinaryseachinteger(): with pytest.raises(TypeError): result = binary(json_string['filebinarysearch'][3]['input1'], json_string['filebinarysearch'][3]['input2']) expected = json_string['filebinarysearch'][3]['output'] assert result == expected
#Sorting the contents content.sort() print("After Sorting : ", content) while True: #getting the wrd to be searched from the user s1 = input("Enter the word to be searched : ") if (s1.isspace()): print("White spaces are not allowed.. please try once more") continue bool = False specialChars = [ "$", "#", "@", "!", "*", "+", "-", ",", "%", "^", "(", ")", "[", "]", "{", "}", ":", ";", "'", "<", ">", "?", "~" ] for i in s1: for j in specialChars: if (i == j): print("No Special characters allowed.. Please try once more") bool = True break if (bool == True): continue if (s1.isdigit() == True): print("Enter words only.. not digits") else: break #calling the function in the BL file pos = utility.binary(content, s1)