def test_invalid_base_valueerror(): with pytest.raises(ValueError): session3.encoded_from_base10(10, -1, '1234567890') with pytest.raises(ValueError): session3.encoded_from_base10(10, 1, '012') with pytest.raises(ValueError): session3.encoded_from_base10(10, 37, '1234567890123456789012345678901234567')
def test_innacurate_digit_map_length(): with pytest.raises(ValueError): session3.encoded_from_base10(123123, 16, '0123456789abcde') with pytest.raises(ValueError): session3.encoded_from_base10(123123, 9, '01234567')
def test_invalid_base_valueerror_provides_relevant_message(): with pytest.raises(ValueError, match=r".* base .*"): session3.encoded_from_base10(10, -1, '1234567890')
def test_repeating_digits_valueerror_provides_relevant_message(): with pytest.raises(ValueError, match=r".* repeating .*"): session3.encoded_from_base10( 10, 10, '012AB012ab' ), 'Something is fishy! You are not using word "repeating" while talking about an error releated to "repeating" alphanumerics!!'
def test_repeating_digits_in_digit_map(): with pytest.raises(ValueError): session3.encoded_from_base10(10, 10, '0123401234')
def test_negative_hexadecimal_conversions(): for _ in range(50): r_num = random.randint(-32700, -1) assert (session3.encoded_from_base10( r_num, 16, '0123456789abcdef').lower()) == '-' + hex( r_num)[3:], f"Your program returned wrong HEX conversions"
def test_hexadecimal_conversions(): for _ in range(50): r_num = random.randint(0, 32767) assert (session3.encoded_from_base10( r_num, 16, '0123456789abcdef').lower()) == hex( r_num)[2:], f"Your program returned wrong HEX conversions"