id
int64
0
401
project
stringclasses
23 values
module
stringlengths
9
38
entry_point
stringlengths
2
33
solution
stringlengths
94
5.46k
prompt
stringlengths
81
33.3k
target_function_prompt
stringlengths
55
2.35k
function_signature
stringlengths
11
364
test
stringlengths
685
102k
test_list
sequence
docstring
stringlengths
14
2.1k
original_docstring
stringlengths
20
2.11k
docstring_tokens
sequence
check
stringlengths
1.79k
103k
cross_context
bool
2 classes
isContained
bool
2 classes
line_coverage
float32
40
100
0
test-apps/python-string-utils
string_utils.manipulation
reverse
def reverse(input_string: str) -> str: """ Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string. """ if not is_string(input_string): raise InvalidInputError(input_string) return input_string[::-1]
import base64 import random import unicodedata import zlib from typing import Union from uuid import uuid4 from ._regex import * from .errors import InvalidInputError from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string class InvalidInputError(TypeError): """ Custom error raised when received object is not a string as expected. """ def __init__(self, input_data: Any): """ :param input_data: Any received object """ type_name = type(input_data).__name__ msg = 'Expected "str", received "{}"'.format(type_name) super().__init__(msg) def is_string(obj: Any) -> bool: """ Checks if an object is a string. *Example:* >>> is_string('foo') # returns true >>> is_string(b'foo') # returns false :param obj: Object to test. :return: True if string, false otherwise. """ return isinstance(obj, str) def reverse(input_string: str) -> str: """ Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string. """
def reverse(input_string: str) -> str: """ Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string. """
def reverse(input_string: str) -> str:
import base64 import random import unicodedata import zlib from typing import Union from uuid import uuid4 from ._regex import * from .errors import InvalidInputError from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string import sys sys.path.insert(1, "/input/test-apps/python-string-utils") import unittest, pytest import math import random import re import copy import datetime import itertools import collections import heapq import statistics import functools import hashlib import numpy import numpy as np import string from typing import * from collections import * import pickle import timeout_decorator from string_utils.manipulation import * # noqa: autoimport from string_utils.manipulation import reverse # noqa: autoimport LOCAL_TIMEOUT = 5 @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_0(): assert reverse("mystring") == "gnirtsym" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_1(): assert reverse('a') == 'a' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_2(): assert reverse('hello') == 'olleh' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_3(): assert reverse('hello world') == 'dlrow olleh' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_4(): assert reverse("hello") == "olleh" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_5(): assert reverse('h') == 'h' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_6(): assert reverse('') == '' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_7(): assert reverse("😀") == "😀" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_8(): assert reverse('abc') == 'cba' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_9(): assert reverse("pizza") == "azzip" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_11(): assert is_string(reverse('hello')) @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_14(): assert reverse('H') == 'H' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_15(): assert reverse('bar') == 'rab' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_16(): assert reverse("AbCdEfG") == "GfEdCbA" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_18(): assert "olleh" == reverse('hello') @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_19(): assert reverse('ab') == 'ba' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_20(): assert reverse('Hello') == 'olleH' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_21(): assert reverse('Hello, World!') == '!dlroW ,olleH' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_22(): assert reverse(reverse("hello")) == "hello" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_23(): assert reverse('Hello World!') == '!dlroW olleH' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_24(): assert reverse("world") == "dlrow" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_25(): assert reverse('world') == 'dlrow' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_26(): assert reverse('lol') == 'lol' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_29(): assert reverse('foo') == 'oof' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_30(): assert reverse(reverse('hello')) == 'hello' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_31(): assert reverse('o') == 'o' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_10(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_10", "rb") as f: output = pickle.load(f) assert reverse('sup?') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_12(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_12", "rb") as f: output = pickle.load(f) assert reverse("A0B$C") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_13(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_13", "rb") as f: output = pickle.load(f) assert reverse("{test}") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_17(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_17", "rb") as f: output = pickle.load(f) assert reverse("ᎾᏍᎩᎾ") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_27(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_27", "rb") as f: output = pickle.load(f) assert reverse("?a123") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_28(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_28", "rb") as f: output = pickle.load(f) assert reverse("software") == output
[ "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_0():\n assert reverse(\"mystring\") == \"gnirtsym\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_1():\n assert reverse('a') == 'a'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_2():\n assert reverse('hello') == 'olleh'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_3():\n assert reverse('hello world') == 'dlrow olleh'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_4():\n assert reverse(\"hello\") == \"olleh\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_5():\n assert reverse('h') == 'h'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_6():\n assert reverse('') == ''", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_7():\n assert reverse(\"😀\") == \"😀\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_8():\n assert reverse('abc') == 'cba'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_9():\n assert reverse(\"pizza\") == \"azzip\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_11():\n assert is_string(reverse('hello'))", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_14():\n assert reverse('H') == 'H'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_15():\n assert reverse('bar') == 'rab'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_16():\n assert reverse(\"AbCdEfG\") == \"GfEdCbA\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_18():\n assert \"olleh\" == reverse('hello')", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_19():\n assert reverse('ab') == 'ba'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_20():\n assert reverse('Hello') == 'olleH'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_21():\n assert reverse('Hello, World!') == '!dlroW ,olleH'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_22():\n assert reverse(reverse(\"hello\")) == \"hello\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_23():\n assert reverse('Hello World!') == '!dlroW olleH'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_24():\n assert reverse(\"world\") == \"dlrow\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_25():\n assert reverse('world') == 'dlrow'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_26():\n assert reverse('lol') == 'lol'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_29():\n assert reverse('foo') == 'oof'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_30():\n assert reverse(reverse('hello')) == 'hello'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_31():\n assert reverse('o') == 'o'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_10():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_10\", \"rb\") as f:\n output = pickle.load(f)\n assert reverse('sup?') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_12():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_12\", \"rb\") as f:\n output = pickle.load(f)\n assert reverse(\"A0B$C\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_13():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_13\", \"rb\") as f:\n output = pickle.load(f)\n assert reverse(\"{test}\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_17():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_17\", \"rb\") as f:\n output = pickle.load(f)\n assert reverse(\"ᎾᏍᎩᎾ\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_27():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_27\", \"rb\") as f:\n output = pickle.load(f)\n assert reverse(\"?a123\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_28():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_28\", \"rb\") as f:\n output = pickle.load(f)\n assert reverse(\"software\") == output" ]
Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string.
""" Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string. """
[ "Returns", "the", "string", "with", "its", "chars", "reversed", ".", "*", "Example", ":", "*", ">>>", "reverse", "(", "'", "hello", "'", ")", "#", "returns", "'", "olleh", "'", ":", "param", "input_string", ":", "String", "to", "revert", ".", ":", "type", "input_string", ":", "str", ":", "return", ":", "Reversed", "string", "." ]
import sys sys.path.insert(1, "/input/test-apps/python-string-utils") import unittest, pytest import math import random import re import copy import datetime import itertools import collections import heapq import statistics import functools import hashlib import numpy import numpy as np import string from typing import * from collections import * import pickle import timeout_decorator __all__ = [ 'camel_case_to_snake', 'snake_case_to_camel', 'reverse', 'shuffle', 'strip_html', 'prettify', 'asciify', 'slugify', 'booleanize', 'strip_margin', 'compress', 'decompress', 'roman_encode', 'roman_decode', ] import base64 import random import unicodedata import zlib from typing import Union from uuid import uuid4 from string_utils._regex import * from string_utils.errors import InvalidInputError from string_utils.validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string class __RomanNumbers: # internal rule mappings for encode() __mappings = [ # units {1: 'I', 5: 'V'}, # tens {1: 'X', 5: 'L'}, # hundreds {1: 'C', 5: 'D'}, # thousands {1: 'M'}, ] # swap key/value definitions for decode() __reversed_mappings = [{v: k for k, v in m.items()} for m in __mappings] @classmethod def __encode_digit(cls, index: int, value: int) -> str: # if digit is zero, there is no sign to display if value == 0: return '' # from 1 to 3 we have just to repeat the sign N times (eg: III, XXX...) if value <= 3: return cls.__mappings[index][1] * value # if 4 we have to add unit prefix if value == 4: return cls.__mappings[index][1] + cls.__mappings[index][5] # if is 5, is a straight map if value == 5: return cls.__mappings[index][5] # if 6, 7 or 8 we have to append unit suffixes if value <= 8: suffix = cls.__mappings[index][1] * (value - 5) return cls.__mappings[index][5] + suffix # if 9 we have to prepend current unit to next return cls.__mappings[index][1] + cls.__mappings[index + 1][1] @classmethod def encode(cls, input_number: Union[str, int]) -> str: # force input conversion to a string (we need it in order to iterate on each digit) input_string = str(input_number) if not is_integer(input_string): raise ValueError('Invalid input, only strings or integers are allowed') value = int(input_string) if value < 1 or value > 3999: raise ValueError('Input must be >= 1 and <= 3999') input_len = len(input_string) output = '' # decode digits from right to left (start from units to thousands) for index in range(input_len): # get actual digit value as int digit = int(input_string[input_len - index - 1]) # encode digit to roman string encoded_digit = cls.__encode_digit(index, digit) # prepend encoded value to the current output in order to have the final string sorted # from thousands to units output = encoded_digit + output return output @classmethod def __index_for_sign(cls, sign: str) -> int: for index, mapping in enumerate(cls.__reversed_mappings): if sign in mapping: return index raise ValueError('Invalid token found: "{}"'.format(sign)) @classmethod def decode(cls, input_string: str) -> int: if not is_full_string(input_string): raise ValueError('Input must be a non empty string') # reverse the provided string so that we can start parsing from units to thousands reversed_string = reverse(input_string.upper()) # track last used value last_value = None # computed number to return output = 0 # for each sign in the string we get its numeric value and add or subtract it to the computed output for sign in reversed_string: # are we dealing with units, tens, hundreds or thousands? index = cls.__index_for_sign(sign) # it's basically 1 or 5 (based on mapping rules definitions) key_value = cls.__reversed_mappings[index][sign] # Based on the level (tens, hundreds...) we have to add as many zeroes as the level into which we are # in order to have the actual sign value. # For instance, if we are at level 2 we are dealing with hundreds, therefore instead of 1 or 5, we will # obtain 100 or 500 by adding 2 zeroes sign_value = int(str(key_value) + '0' * index) # increase total value if we are moving on with level if last_value is None or sign_value >= last_value: output += sign_value # Decrease value if we are back to a previous level # For instance, if we are parsing "IX", we first encounter "X" which is ten then "I" which is unit, # So we have to do the following operation in order to get 9 (the final result): 10 - 1 else: output -= sign_value last_value = sign_value return output class __StringCompressor: @staticmethod def __require_valid_input_and_encoding(input_string: str, encoding: str): if not is_string(input_string): raise InvalidInputError(input_string) if len(input_string) == 0: raise ValueError('Input string cannot be empty') if not is_string(encoding): raise ValueError('Invalid encoding') @classmethod def compress(cls, input_string: str, encoding: str = 'utf-8', compression_level: int = 9) -> str: cls.__require_valid_input_and_encoding(input_string, encoding) if not isinstance(compression_level, int) or compression_level < 0 or compression_level > 9: raise ValueError('Invalid compression_level: it must be an "int" between 0 and 9') # turns input string into a sequence of bytes using provided encoding original_bytes = input_string.encode(encoding) # compress bytes using zlib library compressed_bytes = zlib.compress(original_bytes, compression_level) # encode compressed bytes using base64 # (this ensure that all characters will be available and that the output string can be used safely in any # context such URLs) encoded_bytes = base64.urlsafe_b64encode(compressed_bytes) # finally turns base64 bytes into a string output = encoded_bytes.decode(encoding) return output @classmethod def decompress(cls, input_string: str, encoding: str = 'utf-8') -> str: cls.__require_valid_input_and_encoding(input_string, encoding) # turns input string into a sequence of bytes # (the string is assumed to be a previously compressed string, therefore we have to decode it using base64) input_bytes = base64.urlsafe_b64decode(input_string) # decompress bytes using zlib decompressed_bytes = zlib.decompress(input_bytes) # decode the decompressed bytes to get the original string back original_string = decompressed_bytes.decode(encoding) return original_string class __StringFormatter: def __init__(self, input_string): if not is_string(input_string): raise InvalidInputError(input_string) self.input_string = input_string def __uppercase_first_char(self, regex_match): return regex_match.group(0).upper() def __remove_duplicates(self, regex_match): return regex_match.group(1)[0] def __uppercase_first_letter_after_sign(self, regex_match): match = regex_match.group(1) return match[:-1] + match[2].upper() def __ensure_right_space_only(self, regex_match): return regex_match.group(1).strip() + ' ' def __ensure_left_space_only(self, regex_match): return ' ' + regex_match.group(1).strip() def __ensure_spaces_around(self, regex_match): return ' ' + regex_match.group(1).strip() + ' ' def __remove_internal_spaces(self, regex_match): return regex_match.group(1).strip() def __fix_saxon_genitive(self, regex_match): return regex_match.group(1).replace(' ', '') + ' ' # generates a placeholder to inject temporary into the string, it will be replaced with the original # value at the end of the process @staticmethod def __placeholder_key(): return '$' + uuid4().hex + '$' def format(self) -> str: # map of temporary placeholders placeholders = {} out = self.input_string # looks for url or email and updates placeholders map with found values placeholders.update({self.__placeholder_key(): m[0] for m in URLS_RE.findall(out)}) placeholders.update({self.__placeholder_key(): m for m in EMAILS_RE.findall(out)}) # replace original value with the placeholder key for p in placeholders: out = out.replace(placeholders[p], p, 1) out = PRETTIFY_RE['UPPERCASE_FIRST_LETTER'].sub(self.__uppercase_first_char, out) out = PRETTIFY_RE['DUPLICATES'].sub(self.__remove_duplicates, out) out = PRETTIFY_RE['RIGHT_SPACE'].sub(self.__ensure_right_space_only, out) out = PRETTIFY_RE['LEFT_SPACE'].sub(self.__ensure_left_space_only, out) out = PRETTIFY_RE['SPACES_AROUND'].sub(self.__ensure_spaces_around, out) out = PRETTIFY_RE['SPACES_INSIDE'].sub(self.__remove_internal_spaces, out) out = PRETTIFY_RE['UPPERCASE_AFTER_SIGN'].sub(self.__uppercase_first_letter_after_sign, out) out = PRETTIFY_RE['SAXON_GENITIVE'].sub(self.__fix_saxon_genitive, out) out = out.strip() # restore placeholder keys with their associated original value for p in placeholders: out = out.replace(p, placeholders[p], 1) return out def reverse(input_string: str) -> str: """ Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string. """ if not is_string(input_string): raise InvalidInputError(input_string) return input_string[::-1] def camel_case_to_snake(input_string, separator='_'): """ Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string. """ if not is_string(input_string): raise InvalidInputError(input_string) if not is_camel_case(input_string): return input_string return CAMEL_CASE_REPLACE_RE.sub(lambda m: m.group(1) + separator, input_string).lower() def snake_case_to_camel(input_string: str, upper_case_first: bool = True, separator: str = '_') -> str: """ Convert a snake case string into a camel case one. (The original string is returned if is not a valid snake case string) *Example:* >>> snake_case_to_camel('the_snake_is_green') # returns 'TheSnakeIsGreen' :param input_string: String to convert. :type input_string: str :param upper_case_first: True to turn the first letter into uppercase (default). :type upper_case_first: bool :param separator: Sign to use as separator (default to "_"). :type separator: str :return: Converted string """ if not is_string(input_string): raise InvalidInputError(input_string) if not is_snake_case(input_string, separator): return input_string tokens = [s.title() for s in input_string.split(separator) if is_full_string(s)] if not upper_case_first: tokens[0] = tokens[0].lower() out = ''.join(tokens) return out def shuffle(input_string: str) -> str: """ Return a new string containing same chars of the given one but in a randomized order. *Example:* >>> shuffle('hello world') # possible output: 'l wodheorll' :param input_string: String to shuffle :type input_string: str :return: Shuffled string """ if not is_string(input_string): raise InvalidInputError(input_string) # turn the string into a list of chars chars = list(input_string) # shuffle the list random.shuffle(chars) # convert the shuffled list back to string return ''.join(chars) def strip_html(input_string: str, keep_tag_content: bool = False) -> str: """ Remove html code contained into the given string. *Examples:* >>> strip_html('test: <a href="foo/bar">click here</a>') # returns 'test: ' >>> strip_html('test: <a href="foo/bar">click here</a>', keep_tag_content=True) # returns 'test: click here' :param input_string: String to manipulate. :type input_string: str :param keep_tag_content: True to preserve tag content, False to remove tag and its content too (default). :type keep_tag_content: bool :return: String with html removed. """ if not is_string(input_string): raise InvalidInputError(input_string) r = HTML_TAG_ONLY_RE if keep_tag_content else HTML_RE return r.sub('', input_string) def prettify(input_string: str) -> str: """ Reformat a string by applying the following basic grammar and formatting rules: - String cannot start or end with spaces - The first letter in the string and the ones after a dot, an exclamation or a question mark must be uppercase - String cannot have multiple sequential spaces, empty lines or punctuation (except for "?", "!" and ".") - Arithmetic operators (+, -, /, \\*, =) must have one, and only one space before and after themselves - One, and only one space should follow a dot, a comma, an exclamation or a question mark - Text inside double quotes cannot start or end with spaces, but one, and only one space must come first and \ after quotes (foo" bar"baz -> foo "bar" baz) - Text inside round brackets cannot start or end with spaces, but one, and only one space must come first and \ after brackets ("foo(bar )baz" -> "foo (bar) baz") - Percentage sign ("%") cannot be preceded by a space if there is a number before ("100 %" -> "100%") - Saxon genitive is correct ("Dave' s dog" -> "Dave's dog") *Examples:* >>> prettify(' unprettified string ,, like this one,will be"prettified" .it\\' s awesome! ') >>> # -> 'Unprettified string, like this one, will be "prettified". It\'s awesome!' :param input_string: String to manipulate :return: Prettified string. """ formatted = __StringFormatter(input_string).format() return formatted def asciify(input_string: str) -> str: """ Force string content to be ascii-only by translating all non-ascii chars into the closest possible representation (eg: ó -> o, Ë -> E, ç -> c...). **Bear in mind**: Some chars may be lost if impossible to translate. *Example:* >>> asciify('èéùúòóäåëýñÅÀÁÇÌÍÑÓË') # returns 'eeuuooaaeynAAACIINOE' :param input_string: String to convert :return: Ascii utf-8 string """ if not is_string(input_string): raise InvalidInputError(input_string) # "NFKD" is the algorithm which is able to successfully translate the most of non-ascii chars normalized = unicodedata.normalize('NFKD', input_string) # encode string forcing ascii and ignore any errors (unrepresentable chars will be stripped out) ascii_bytes = normalized.encode('ascii', 'ignore') # turns encoded bytes into an utf-8 string ascii_string = ascii_bytes.decode('utf-8') return ascii_string def slugify(input_string: str, separator: str = '-') -> str: """ Converts a string into a "slug" using provided separator. The returned string has the following properties: - it has no spaces - all letters are in lower case - all punctuation signs and non alphanumeric chars are removed - words are divided using provided separator - all chars are encoded as ascii (by using `asciify()`) - is safe for URL *Examples:* >>> slugify('Top 10 Reasons To Love Dogs!!!') # returns: 'top-10-reasons-to-love-dogs' >>> slugify('Mönstér Mägnët') # returns 'monster-magnet' :param input_string: String to convert. :type input_string: str :param separator: Sign used to join string tokens (default to "-"). :type separator: str :return: Slug string """ if not is_string(input_string): raise InvalidInputError(input_string) # replace any character that is NOT letter or number with spaces out = NO_LETTERS_OR_NUMBERS_RE.sub(' ', input_string.lower()).strip() # replace spaces with join sign out = SPACES_RE.sub(separator, out) # normalize joins (remove duplicates) out = re.sub(re.escape(separator) + r'+', separator, out) return asciify(out) def booleanize(input_string: str) -> bool: """ Turns a string into a boolean based on its content (CASE INSENSITIVE). A positive boolean (True) is returned if the string value is one of the following: - "true" - "1" - "yes" - "y" Otherwise False is returned. *Examples:* >>> booleanize('true') # returns True >>> booleanize('YES') # returns True >>> booleanize('nope') # returns False :param input_string: String to convert :type input_string: str :return: True if the string contains a boolean-like positive value, false otherwise """ if not is_string(input_string): raise InvalidInputError(input_string) return input_string.lower() in ('true', '1', 'yes', 'y') def strip_margin(input_string: str) -> str: """ Removes tab indentation from multi line strings (inspired by analogous Scala function). *Example:* >>> strip_margin(''' >>> line 1 >>> line 2 >>> line 3 >>> ''') >>> # returns: >>> ''' >>> line 1 >>> line 2 >>> line 3 >>> ''' :param input_string: String to format :type input_string: str :return: A string without left margins """ if not is_string(input_string): raise InvalidInputError(input_string) line_separator = '\n' lines = [MARGIN_RE.sub('', line) for line in input_string.split(line_separator)] out = line_separator.join(lines) return out def compress(input_string: str, encoding: str = 'utf-8', compression_level: int = 9) -> str: """ Compress the given string by returning a shorter one that can be safely used in any context (like URL) and restored back to its original state using `decompress()`. **Bear in mind:** Besides the provided `compression_level`, the compression result (how much the string is actually compressed by resulting into a shorter string) depends on 2 factors: 1. The amount of data (string size): short strings might not provide a significant compression result\ or even be longer than the given input string (this is due to the fact that some bytes have to be embedded\ into the compressed string in order to be able to restore it later on)\ 2. The content type: random sequences of chars are very unlikely to be successfully compressed, while the best\ compression result is obtained when the string contains several recurring char sequences (like in the example). Behind the scenes this method makes use of the standard Python's zlib and base64 libraries. *Examples:* >>> n = 0 # <- ignore this, it's a fix for Pycharm (not fixable using ignore comments) >>> # "original" will be a string with 169 chars: >>> original = ' '.join(['word n{}'.format(n) for n in range(20)]) >>> # "compressed" will be a string of 88 chars >>> compressed = compress(original) :param input_string: String to compress (must be not empty or a ValueError will be raised). :type input_string: str :param encoding: String encoding (default to "utf-8"). :type encoding: str :param compression_level: A value between 0 (no compression) and 9 (best compression), default to 9. :type compression_level: int :return: Compressed string. """ return __StringCompressor.compress(input_string, encoding, compression_level) def decompress(input_string: str, encoding: str = 'utf-8') -> str: """ Restore a previously compressed string (obtained using `compress()`) back to its original state. :param input_string: String to restore. :type input_string: str :param encoding: Original string encoding. :type encoding: str :return: Decompressed string. """ return __StringCompressor.decompress(input_string, encoding) def roman_encode(input_number: Union[str, int]) -> str: """ Convert the given number/string into a roman number. The passed input must represents a positive integer in the range 1-3999 (inclusive). Why this limit? You may be wondering: 1. zero is forbidden since there is no related representation in roman numbers 2. the upper bound 3999 is due to the limitation in the ascii charset\ (the higher quantity sign displayable in ascii is "M" which is equal to 1000, therefore based on\ roman numbers rules we can use 3 times M to reach 3000 but we can't go any further in thousands without\ special "boxed chars"). *Examples:* >>> roman_encode(37) # returns 'XXXVIII' >>> roman_encode('2020') # returns 'MMXX' :param input_number: An integer or a string to be converted. :type input_number: Union[str, int] :return: Roman number string. """ return __RomanNumbers.encode(input_number) def roman_decode(input_string: str) -> int: """ Decode a roman number string into an integer if the provided string is valid. *Example:* >>> roman_decode('VII') # returns 7 :param input_string: (Assumed) Roman number :type input_string: str :return: Integer value """ return __RomanNumbers.decode(input_string) import pickle def test_0(): assert reverse("mystring") == "gnirtsym" test_0() def test_1(): assert reverse('a') == 'a' test_1() def test_2(): assert reverse('hello') == 'olleh' test_2() def test_3(): assert reverse('hello world') == 'dlrow olleh' test_3() def test_4(): assert reverse("hello") == "olleh" test_4() def test_5(): assert reverse('h') == 'h' test_5() def test_6(): assert reverse('') == '' test_6() def test_7(): assert reverse("😀") == "😀" test_7() def test_8(): assert reverse('abc') == 'cba' test_8() def test_9(): assert reverse("pizza") == "azzip" test_9() def test_11(): assert is_string(reverse('hello')) test_11() def test_14(): assert reverse('H') == 'H' test_14() def test_15(): assert reverse('bar') == 'rab' test_15() def test_16(): assert reverse("AbCdEfG") == "GfEdCbA" test_16() def test_18(): assert "olleh" == reverse('hello') test_18() def test_19(): assert reverse('ab') == 'ba' test_19() def test_20(): assert reverse('Hello') == 'olleH' test_20() def test_21(): assert reverse('Hello, World!') == '!dlroW ,olleH' test_21() def test_22(): assert reverse(reverse("hello")) == "hello" test_22() def test_23(): assert reverse('Hello World!') == '!dlroW olleH' test_23() def test_24(): assert reverse("world") == "dlrow" test_24() def test_25(): assert reverse('world') == 'dlrow' test_25() def test_26(): assert reverse('lol') == 'lol' test_26() def test_29(): assert reverse('foo') == 'oof' test_29() def test_30(): assert reverse(reverse('hello')) == 'hello' test_30() def test_31(): assert reverse('o') == 'o' test_31() def test_10(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_10", "rb") as f: output = pickle.load(f) assert reverse('sup?') == output test_10() def test_12(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_12", "rb") as f: output = pickle.load(f) assert reverse("A0B$C") == output test_12() def test_13(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_13", "rb") as f: output = pickle.load(f) assert reverse("{test}") == output test_13() def test_17(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_17", "rb") as f: output = pickle.load(f) assert reverse("ᎾᏍᎩᎾ") == output test_17() def test_27(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_27", "rb") as f: output = pickle.load(f) assert reverse("?a123") == output test_27() def test_28(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/reverse/test_28", "rb") as f: output = pickle.load(f) assert reverse("software") == output test_28()
true
false
66.666664
1
test-apps/python-string-utils
string_utils.manipulation
camel_case_to_snake
def camel_case_to_snake(input_string, separator='_'): """ Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string. """ if not is_string(input_string): raise InvalidInputError(input_string) if not is_camel_case(input_string): return input_string return CAMEL_CASE_REPLACE_RE.sub(lambda m: m.group(1) + separator, input_string).lower()
import base64 import random import unicodedata import zlib from typing import Union from uuid import uuid4 from ._regex import * from .errors import InvalidInputError from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string CAMEL_CASE_REPLACE_RE = re.compile(r'([a-z]|[A-Z]+)(?=[A-Z])') class InvalidInputError(TypeError): """ Custom error raised when received object is not a string as expected. """ def __init__(self, input_data: Any): """ :param input_data: Any received object """ type_name = type(input_data).__name__ msg = 'Expected "str", received "{}"'.format(type_name) super().__init__(msg) def is_string(obj: Any) -> bool: """ Checks if an object is a string. *Example:* >>> is_string('foo') # returns true >>> is_string(b'foo') # returns false :param obj: Object to test. :return: True if string, false otherwise. """ return isinstance(obj, str) def is_camel_case(input_string: Any) -> bool: """ Checks if a string is formatted as camel case. A string is considered camel case when: - it's composed only by letters ([a-zA-Z]) and optionally numbers ([0-9]) - it contains both lowercase and uppercase letters - it does not start with a number *Examples:* >>> is_camel_case('MyString') # returns true >>> is_camel_case('mystring') # returns false :param input_string: String to test. :type input_string: str :return: True for a camel case string, false otherwise. """ return is_full_string(input_string) and CAMEL_CASE_TEST_RE.match(input_string) is not None def camel_case_to_snake(input_string, separator='_'): """ Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string. """
def camel_case_to_snake(input_string, separator='_'): """ Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string. """
def camel_case_to_snake(input_string, separator='_'):
import base64 import random import unicodedata import zlib from typing import Union from uuid import uuid4 from ._regex import * from .errors import InvalidInputError from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string import sys sys.path.insert(1, "/input/test-apps/python-string-utils") import unittest, pytest import math import random import re import copy import datetime import itertools import collections import heapq import statistics import functools import hashlib import numpy import numpy as np import string from typing import * from collections import * import pickle import timeout_decorator from string_utils.manipulation import * # noqa: autoimport from string_utils.manipulation import camel_case_to_snake # noqa: autoimport LOCAL_TIMEOUT = 5 @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_0(): assert camel_case_to_snake("MySuperCamelCaseString") == "my_super_camel_case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_1(): assert camel_case_to_snake('') == '' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_2(): assert camel_case_to_snake('this_is_not_a_camel_case_string_test') == 'this_is_not_a_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_3(): assert camel_case_to_snake('123') == '123' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_5(): assert camel_case_to_snake("Case") == "case" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_7(): assert camel_case_to_snake('ThisIsACamelCaseStringTest') == 'this_is_a_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_8(): assert camel_case_to_snake('this_is_snake') == 'this_is_snake' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_9(): assert camel_case_to_snake('ThisIsNotACamelStringTest') == 'this_is_not_a_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_10(): assert camel_case_to_snake('This') == 'this' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_15(): assert camel_case_to_snake('aB2def') == 'a_b2def' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_17(): assert camel_case_to_snake('aBc1def') == 'a_bc1def' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_20(): assert camel_case_to_snake('test2case234') == 'test2case234' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_21(): assert camel_case_to_snake("camelCaseString") == "camel_case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_22(): assert camel_case_to_snake('camel123') == 'camel123' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_23(): assert camel_case_to_snake('ACamelString') == 'a_camel_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_26(): assert camel_case_to_snake("one2three4") == "one2three4" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_30(): assert camel_case_to_snake('TestCase234') == 'test_case234' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_32(): assert camel_case_to_snake("ThisIsACamelCaseString") == "this_is_a_camel_case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_33(): assert camel_case_to_snake('this_is_a_camel_case_string_test') == 'this_is_a_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_35(): assert camel_case_to_snake('1') == '1' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_39(): assert camel_case_to_snake('thisIsATestString') == 'this_is_a_test_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_41(): assert camel_case_to_snake('ThisIsCamelCase') == 'this_is_camel_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_43(): assert camel_case_to_snake('ThisIsACamelCaseStringTest12') == 'this_is_a_camel_case_string_test12' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_44(): assert camel_case_to_snake('thisIsACamelCaseStringTest', '*') == 'this*is*a*camel*case*string*test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_46(): assert camel_case_to_snake('testCase') == 'test_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_47(): assert camel_case_to_snake('thisIs') == 'this_is' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_48(): assert camel_case_to_snake("") == '' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_51(): assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest123') == 'this_is_also_not_a_camel_case_string_test123' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_54(): assert camel_case_to_snake('this_is_a_camel_case_string_test_with_underscores') == 'this_is_a_camel_case_string_test_with_underscores' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_59(): assert camel_case_to_snake('AnotherTest') == 'another_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_62(): assert camel_case_to_snake("ACamelCaseString") == "a_camel_case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_63(): assert camel_case_to_snake('TestCase2') == 'test_case2' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_64(): assert camel_case_to_snake('this_is_not_a_camel_case_string') == 'this_is_not_a_camel_case_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_65(): assert camel_case_to_snake('ThisIsACamelStringTest', '') == 'thisisacamelstringtest' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_68(): assert camel_case_to_snake('MyString') == 'my_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_71(): assert camel_case_to_snake('ThisIsACamelStringTest', '...') == 'this...is...a...camel...string...test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_72(): assert camel_case_to_snake("CCamelCase") == "c_camel_case" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_73(): assert camel_case_to_snake('CamelCaseToSnakeWithNumber1') == 'camel_case_to_snake_with_number1' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_74(): assert camel_case_to_snake('ThisIsCamelCaseWithNumber123') == 'this_is_camel_case_with_number123' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_75(): assert camel_case_to_snake('ThisIsAnotherCamelStringTest') == 'this_is_another_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_77(): assert camel_case_to_snake('Test') == 'test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_78(): assert camel_case_to_snake('123camel') == '123camel' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_79(): assert camel_case_to_snake('AaBbCc') == 'aa_bb_cc' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_80(): assert camel_case_to_snake('this_is_a_snake_case_string_test') == 'this_is_a_snake_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_81(): assert camel_case_to_snake('CamelStringTest') == 'camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_82(): assert camel_case_to_snake('ThisIsACamelStringTest', '-') == 'this-is-a-camel-string-test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_85(): assert camel_case_to_snake('ThisIsAReallyVeryVeryLongCamelCaseStringTest') == 'this_is_a_really_very_very_long_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_87(): assert camel_case_to_snake('ThisIsAnotherCamelCase') == 'this_is_another_camel_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_89(): assert camel_case_to_snake("ThisIsACamelCaseStringTest") == 'this_is_a_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_91(): assert camel_case_to_snake("MyString") == "my_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_92(): assert camel_case_to_snake('ThisIsACamelCaseStringTest1') == 'this_is_a_camel_case_string_test1' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_96(): assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest12345') == 'this_is_also_not_a_camel_case_string_test12345' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_97(): assert camel_case_to_snake('CamelCaseToSnake') == 'camel_case_to_snake' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_98(): assert camel_case_to_snake("ThisIsACamelStringTest") == "this_is_a_camel_string_test" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_100(): assert camel_case_to_snake('my_string_test') == 'my_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_101(): assert camel_case_to_snake('thisIsAnotherCamel') == 'this_is_another_camel' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_103(): assert camel_case_to_snake('this_is_not_a_camel_string_test') == 'this_is_not_a_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_104(): assert camel_case_to_snake("CamelCaseString") == "camel_case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_106(): assert camel_case_to_snake('TestCase') == 'test_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_109(): assert camel_case_to_snake('ThisIsACamel') == 'this_is_a_camel' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_110(): assert camel_case_to_snake('ThisIsACamelCaseStringTest123') == 'this_is_a_camel_case_string_test123' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_113(): assert camel_case_to_snake("CaseString") == "case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_114(): assert camel_case_to_snake('ThisIsACamelCaseString') == 'this_is_a_camel_case_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_115(): assert camel_case_to_snake('ThisIsCamel') == 'this_is_camel' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_116(): assert camel_case_to_snake('ThisIsATestString') == 'this_is_a_test_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_117(): assert camel_case_to_snake('abc1def') == 'abc1def' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_118(): assert camel_case_to_snake('ThisIsACamelCaseString987') == 'this_is_a_camel_case_string987' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_121(): assert camel_case_to_snake('ThisIsaCamelCaseString') == 'this_isa_camel_case_string' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_122(): assert camel_case_to_snake('aB') == 'a_b' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_123(): assert camel_case_to_snake('testCase2') == 'test_case2' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_124(): assert camel_case_to_snake("MyCamelCaseString") == "my_camel_case_string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_125(): assert camel_case_to_snake('CamelCase') == 'camel_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_126(): assert camel_case_to_snake("Camel") == "camel" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_127(): assert camel_case_to_snake("thisIsACamelCaseStringTest") == "this_is_a_camel_case_string_test" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_128(): assert camel_case_to_snake('ThisIsATestForLowerCase') == 'this_is_a_test_for_lower_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_129(): assert camel_case_to_snake('ThisIsACamelStringTest', '_') == 'this_is_a_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_131(): assert camel_case_to_snake('ThisIsAStringTest') == 'this_is_a_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_132(): assert camel_case_to_snake('ThisIsACamelStringTest') == 'this_is_a_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_133(): assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest') == 'this_is_also_not_a_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_134(): assert camel_case_to_snake('thisIsACamelCaseStringTest') == 'this_is_a_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_135(): assert camel_case_to_snake('thisIsCamel') == 'this_is_camel' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_138(): assert camel_case_to_snake('ab2def') == 'ab2def' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_140(): assert camel_case_to_snake('thisIsACamelStringTest') == 'this_is_a_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_143(): assert camel_case_to_snake('camelCase') == 'camel_case' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_145(): assert camel_case_to_snake('ThisIsCamelCaseStringTest') == 'this_is_camel_case_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_146(): assert camel_case_to_snake("MySuperCamelCaseString", "@") == "my@super@camel@case@string" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_147(): assert camel_case_to_snake('thisIsACamelCaseStringTest', '+') == 'this+is+a+camel+case+string+test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_149(): assert camel_case_to_snake("HelloWorld") == 'hello_world' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_151(): assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == 'this is a camel string test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_152(): assert camel_case_to_snake('this') == 'this' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_153(): assert camel_case_to_snake('TeSt') == 'te_st' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_154(): assert camel_case_to_snake("CamelCase") == "camel_case" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_156(): assert camel_case_to_snake('AnotherCamelStringTest') == 'another_camel_string_test' @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_159(): assert camel_case_to_snake("aAaA") == "a_aa_a" @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_4(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_4", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('AB') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_6(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_6", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('test2Case234') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_11(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_11", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_12(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_12", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMelCaseString") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_13(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_13", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsNotACamelCaseString') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_14(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_14", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelString_Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_16(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_16", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelCaseString123TestABC') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_18(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_18", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("One2Three4") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_19(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_19", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("mySuperCamelCaseString") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_24(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_24", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', '.') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_25(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_25", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("ThisIsA_CAMELCaseStringTest_Test") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_27(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_27", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_28(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_28", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('This_Is_A_Camel_Case_String_Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_29(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_29", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('_ThisIsACamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_31(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_31", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamel2StringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_34(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_34", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('This_Is_A_Camel_Case_String_123Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_36(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_36", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('Test2Case234') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_37(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_37", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('test1Case') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_38(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_38", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('1A') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_40(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_40", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('A1') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_42(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_42", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsAnotherCamelCaseStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_45(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_45", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('This_is_not_a_camel_case_string_test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_49(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_49", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('T') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_50(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_50", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('THISISSHOUTCASE') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_52(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_52", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelCaseString123Test123') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_53(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_53", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('TestTEST') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_55(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_55", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelCaseString123Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_56(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_56", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMELCaseStringTest_Test") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_57(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_57", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('TEST') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_58(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_58", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelString2Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_60(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_60", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('A1B') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_61(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_61", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_66(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_66", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("One2Three") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_67(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_67", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamelString2Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_69(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_69", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsA2CamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_70(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_70", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMELCaseString") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_76(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_76", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("A1B2C3") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_83(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_83", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTestWithoutSeparator', '') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_84(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_84", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('THIS_IS_NOT_A_CAMEL_CASE_STRING_TEST') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_86(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_86", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CamelCaseString") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_88(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_88", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('this_Is_a_CaMel_case_String_Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_90(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_90", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTestWithDigits123') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_93(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_93", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs_CamelCase') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_94(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_94", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('123thisIsNotAString') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_95(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_95", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTestWithoutSeparator') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_99(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_99", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_102(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_102", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamel2StringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_105(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_105", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_107(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_107", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('thisIsNotACamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_108(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_108", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelString') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_111(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_111", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsSnake_Case') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_112(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_112", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('345thisIsNotAString') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_119(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_119", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMELCaseStringTest") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_120(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_120", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_130(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_130", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('thisIsNotAString') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_136(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_136", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CamelCaseString_Test") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_137(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_137", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamel2String2Test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_139(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_139", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('tHISiS_a_CaMel_CASE_sTrinG_TEST') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_141(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_141", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsaCamelString') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_142(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_142", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', '-') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_144(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_144", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('thisIsACamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_148(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_148", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('TEST2test') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_150(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_150", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('THISiS_a_CaMel_CASE_sTrinG_TEST') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_155(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_155", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsAnotherCamelStringTest') == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_157(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_157", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CamelCaseStringTest") == output @timeout_decorator.timeout(LOCAL_TIMEOUT) def test_158(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_158", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', separator='') == output
[ "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_0():\n assert camel_case_to_snake(\"MySuperCamelCaseString\") == \"my_super_camel_case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_1():\n assert camel_case_to_snake('') == ''", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_2():\n assert camel_case_to_snake('this_is_not_a_camel_case_string_test') == 'this_is_not_a_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_3():\n assert camel_case_to_snake('123') == '123'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_5():\n assert camel_case_to_snake(\"Case\") == \"case\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_7():\n assert camel_case_to_snake('ThisIsACamelCaseStringTest') == 'this_is_a_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_8():\n assert camel_case_to_snake('this_is_snake') == 'this_is_snake'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_9():\n assert camel_case_to_snake('ThisIsNotACamelStringTest') == 'this_is_not_a_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_10():\n assert camel_case_to_snake('This') == 'this'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_15():\n assert camel_case_to_snake('aB2def') == 'a_b2def'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_17():\n assert camel_case_to_snake('aBc1def') == 'a_bc1def'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_20():\n assert camel_case_to_snake('test2case234') == 'test2case234'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_21():\n assert camel_case_to_snake(\"camelCaseString\") == \"camel_case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_22():\n assert camel_case_to_snake('camel123') == 'camel123'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_23():\n assert camel_case_to_snake('ACamelString') == 'a_camel_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_26():\n assert camel_case_to_snake(\"one2three4\") == \"one2three4\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_30():\n assert camel_case_to_snake('TestCase234') == 'test_case234'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_32():\n assert camel_case_to_snake(\"ThisIsACamelCaseString\") == \"this_is_a_camel_case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_33():\n assert camel_case_to_snake('this_is_a_camel_case_string_test') == 'this_is_a_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_35():\n assert camel_case_to_snake('1') == '1'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_39():\n assert camel_case_to_snake('thisIsATestString') == 'this_is_a_test_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_41():\n assert camel_case_to_snake('ThisIsCamelCase') == 'this_is_camel_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_43():\n assert camel_case_to_snake('ThisIsACamelCaseStringTest12') == 'this_is_a_camel_case_string_test12'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_44():\n assert camel_case_to_snake('thisIsACamelCaseStringTest', '*') == 'this*is*a*camel*case*string*test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_46():\n assert camel_case_to_snake('testCase') == 'test_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_47():\n assert camel_case_to_snake('thisIs') == 'this_is'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_48():\n assert camel_case_to_snake(\"\") == ''", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_51():\n assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest123') == 'this_is_also_not_a_camel_case_string_test123'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_54():\n assert camel_case_to_snake('this_is_a_camel_case_string_test_with_underscores') == 'this_is_a_camel_case_string_test_with_underscores'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_59():\n assert camel_case_to_snake('AnotherTest') == 'another_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_62():\n assert camel_case_to_snake(\"ACamelCaseString\") == \"a_camel_case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_63():\n assert camel_case_to_snake('TestCase2') == 'test_case2'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_64():\n assert camel_case_to_snake('this_is_not_a_camel_case_string') == 'this_is_not_a_camel_case_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_65():\n assert camel_case_to_snake('ThisIsACamelStringTest', '') == 'thisisacamelstringtest'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_68():\n assert camel_case_to_snake('MyString') == 'my_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_71():\n assert camel_case_to_snake('ThisIsACamelStringTest', '...') == 'this...is...a...camel...string...test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_72():\n assert camel_case_to_snake(\"CCamelCase\") == \"c_camel_case\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_73():\n assert camel_case_to_snake('CamelCaseToSnakeWithNumber1') == 'camel_case_to_snake_with_number1'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_74():\n assert camel_case_to_snake('ThisIsCamelCaseWithNumber123') == 'this_is_camel_case_with_number123'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_75():\n assert camel_case_to_snake('ThisIsAnotherCamelStringTest') == 'this_is_another_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_77():\n assert camel_case_to_snake('Test') == 'test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_78():\n assert camel_case_to_snake('123camel') == '123camel'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_79():\n assert camel_case_to_snake('AaBbCc') == 'aa_bb_cc'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_80():\n assert camel_case_to_snake('this_is_a_snake_case_string_test') == 'this_is_a_snake_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_81():\n assert camel_case_to_snake('CamelStringTest') == 'camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_82():\n assert camel_case_to_snake('ThisIsACamelStringTest', '-') == 'this-is-a-camel-string-test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_85():\n assert camel_case_to_snake('ThisIsAReallyVeryVeryLongCamelCaseStringTest') == 'this_is_a_really_very_very_long_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_87():\n assert camel_case_to_snake('ThisIsAnotherCamelCase') == 'this_is_another_camel_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_89():\n assert camel_case_to_snake(\"ThisIsACamelCaseStringTest\") == 'this_is_a_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_91():\n assert camel_case_to_snake(\"MyString\") == \"my_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_92():\n assert camel_case_to_snake('ThisIsACamelCaseStringTest1') == 'this_is_a_camel_case_string_test1'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_96():\n assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest12345') == 'this_is_also_not_a_camel_case_string_test12345'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_97():\n assert camel_case_to_snake('CamelCaseToSnake') == 'camel_case_to_snake'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_98():\n assert camel_case_to_snake(\"ThisIsACamelStringTest\") == \"this_is_a_camel_string_test\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_100():\n assert camel_case_to_snake('my_string_test') == 'my_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_101():\n assert camel_case_to_snake('thisIsAnotherCamel') == 'this_is_another_camel'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_103():\n assert camel_case_to_snake('this_is_not_a_camel_string_test') == 'this_is_not_a_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_104():\n assert camel_case_to_snake(\"CamelCaseString\") == \"camel_case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_106():\n assert camel_case_to_snake('TestCase') == 'test_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_109():\n assert camel_case_to_snake('ThisIsACamel') == 'this_is_a_camel'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_110():\n assert camel_case_to_snake('ThisIsACamelCaseStringTest123') == 'this_is_a_camel_case_string_test123'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_113():\n assert camel_case_to_snake(\"CaseString\") == \"case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_114():\n assert camel_case_to_snake('ThisIsACamelCaseString') == 'this_is_a_camel_case_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_115():\n assert camel_case_to_snake('ThisIsCamel') == 'this_is_camel'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_116():\n assert camel_case_to_snake('ThisIsATestString') == 'this_is_a_test_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_117():\n assert camel_case_to_snake('abc1def') == 'abc1def'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_118():\n assert camel_case_to_snake('ThisIsACamelCaseString987') == 'this_is_a_camel_case_string987'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_121():\n assert camel_case_to_snake('ThisIsaCamelCaseString') == 'this_isa_camel_case_string'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_122():\n assert camel_case_to_snake('aB') == 'a_b'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_123():\n assert camel_case_to_snake('testCase2') == 'test_case2'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_124():\n assert camel_case_to_snake(\"MyCamelCaseString\") == \"my_camel_case_string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_125():\n assert camel_case_to_snake('CamelCase') == 'camel_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_126():\n assert camel_case_to_snake(\"Camel\") == \"camel\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_127():\n assert camel_case_to_snake(\"thisIsACamelCaseStringTest\") == \"this_is_a_camel_case_string_test\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_128():\n assert camel_case_to_snake('ThisIsATestForLowerCase') == 'this_is_a_test_for_lower_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_129():\n assert camel_case_to_snake('ThisIsACamelStringTest', '_') == 'this_is_a_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_131():\n assert camel_case_to_snake('ThisIsAStringTest') == 'this_is_a_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_132():\n assert camel_case_to_snake('ThisIsACamelStringTest') == 'this_is_a_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_133():\n assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest') == 'this_is_also_not_a_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_134():\n assert camel_case_to_snake('thisIsACamelCaseStringTest') == 'this_is_a_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_135():\n assert camel_case_to_snake('thisIsCamel') == 'this_is_camel'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_138():\n assert camel_case_to_snake('ab2def') == 'ab2def'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_140():\n assert camel_case_to_snake('thisIsACamelStringTest') == 'this_is_a_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_143():\n assert camel_case_to_snake('camelCase') == 'camel_case'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_145():\n assert camel_case_to_snake('ThisIsCamelCaseStringTest') == 'this_is_camel_case_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_146():\n assert camel_case_to_snake(\"MySuperCamelCaseString\", \"@\") == \"my@super@camel@case@string\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_147():\n assert camel_case_to_snake('thisIsACamelCaseStringTest', '+') == 'this+is+a+camel+case+string+test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_149():\n assert camel_case_to_snake(\"HelloWorld\") == 'hello_world'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_151():\n assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == 'this is a camel string test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_152():\n assert camel_case_to_snake('this') == 'this'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_153():\n assert camel_case_to_snake('TeSt') == 'te_st'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_154():\n assert camel_case_to_snake(\"CamelCase\") == \"camel_case\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_156():\n assert camel_case_to_snake('AnotherCamelStringTest') == 'another_camel_string_test'", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_159():\n assert camel_case_to_snake(\"aAaA\") == \"a_aa_a\"", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_4():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_4\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('AB') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_6():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_6\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('test2Case234') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_11():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_11\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_12():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_12\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CAMelCaseString\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_13():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_13\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsNotACamelCaseString') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_14():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_14\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelString_Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_16():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_16\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelCaseString123TestABC') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_18():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_18\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"One2Three4\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_19():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_19\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"mySuperCamelCaseString\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_24():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_24\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', '.') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_25():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_25\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"ThisIsA_CAMELCaseStringTest_Test\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_27():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_27\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_28():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_28\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('This_Is_A_Camel_Case_String_Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_29():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_29\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('_ThisIsACamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_31():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_31\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamel2StringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_34():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_34\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('This_Is_A_Camel_Case_String_123Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_36():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_36\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('Test2Case234') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_37():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_37\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('test1Case') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_38():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_38\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('1A') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_40():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_40\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('A1') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_42():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_42\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsAnotherCamelCaseStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_45():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_45\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('This_is_not_a_camel_case_string_test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_49():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_49\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('T') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_50():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_50\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('THISISSHOUTCASE') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_52():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_52\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelCaseString123Test123') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_53():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_53\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('TestTEST') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_55():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_55\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelCaseString123Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_56():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_56\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CAMELCaseStringTest_Test\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_57():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_57\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('TEST') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_58():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_58\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelString2Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_60():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_60\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('A1B') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_61():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_61\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIs2ACamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_66():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_66\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"One2Three\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_67():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_67\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIs2ACamelString2Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_69():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_69\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsA2CamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_70():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_70\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CAMELCaseString\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_76():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_76\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"A1B2C3\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_83():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_83\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTestWithoutSeparator', '') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_84():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_84\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('THIS_IS_NOT_A_CAMEL_CASE_STRING_TEST') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_86():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_86\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CamelCaseString\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_88():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_88\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('this_Is_a_CaMel_case_String_Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_90():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_90\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTestWithDigits123') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_93():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_93\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIs_CamelCase') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_94():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_94\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('123thisIsNotAString') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_95():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_95\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTestWithoutSeparator') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_99():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_99\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_102():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_102\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIs2ACamel2StringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_105():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_105\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_107():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_107\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('thisIsNotACamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_108():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_108\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelString') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_111():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_111\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsSnake_Case') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_112():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_112\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('345thisIsNotAString') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_119():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_119\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CAMELCaseStringTest\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_120():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_120\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_130():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_130\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('thisIsNotAString') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_136():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_136\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CamelCaseString_Test\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_137():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_137\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIs2ACamel2String2Test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_139():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_139\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('tHISiS_a_CaMel_CASE_sTrinG_TEST') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_141():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_141\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsaCamelString') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_142():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_142\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', '-') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_144():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_144\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('thisIsACamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_148():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_148\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('TEST2test') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_150():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_150\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('THISiS_a_CaMel_CASE_sTrinG_TEST') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_155():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_155\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsAnotherCamelStringTest') == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_157():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_157\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake(\"thisIsA_CamelCaseStringTest\") == output", "@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_158():\n with open(\"/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_158\", \"rb\") as f:\n output = pickle.load(f)\n assert camel_case_to_snake('ThisIsACamelStringTest', separator='') == output" ]
Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string.
""" Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string. """
[ "Convert", "a", "camel", "case", "string", "into", "a", "snake", "case", "one", ".", "(", "The", "original", "string", "is", "returned", "if", "is", "not", "a", "valid", "camel", "case", "string", ")", "*", "Example", ":", "*", ">>>", "camel_case_to_snake", "(", "'", "ThisIsACamelStringTest", "'", ")", "#", "returns", "'", "this_is_a_camel_case_string_test", "'", ":", "param", "input_string", ":", "String", "to", "convert", ".", ":", "type", "input_string", ":", "str", ":", "param", "separator", ":", "Sign", "to", "use", "as", "separator", ".", ":", "type", "separator", ":", "str", ":", "return", ":", "Converted", "string", "." ]
import sys sys.path.insert(1, "/input/test-apps/python-string-utils") import unittest, pytest import math import random import re import copy import datetime import itertools import collections import heapq import statistics import functools import hashlib import numpy import numpy as np import string from typing import * from collections import * import pickle import timeout_decorator __all__ = [ 'camel_case_to_snake', 'snake_case_to_camel', 'reverse', 'shuffle', 'strip_html', 'prettify', 'asciify', 'slugify', 'booleanize', 'strip_margin', 'compress', 'decompress', 'roman_encode', 'roman_decode', ] import base64 import random import unicodedata import zlib from typing import Union from uuid import uuid4 from string_utils._regex import * from string_utils.errors import InvalidInputError from string_utils.validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string class __RomanNumbers: # internal rule mappings for encode() __mappings = [ # units {1: 'I', 5: 'V'}, # tens {1: 'X', 5: 'L'}, # hundreds {1: 'C', 5: 'D'}, # thousands {1: 'M'}, ] # swap key/value definitions for decode() __reversed_mappings = [{v: k for k, v in m.items()} for m in __mappings] @classmethod def __encode_digit(cls, index: int, value: int) -> str: # if digit is zero, there is no sign to display if value == 0: return '' # from 1 to 3 we have just to repeat the sign N times (eg: III, XXX...) if value <= 3: return cls.__mappings[index][1] * value # if 4 we have to add unit prefix if value == 4: return cls.__mappings[index][1] + cls.__mappings[index][5] # if is 5, is a straight map if value == 5: return cls.__mappings[index][5] # if 6, 7 or 8 we have to append unit suffixes if value <= 8: suffix = cls.__mappings[index][1] * (value - 5) return cls.__mappings[index][5] + suffix # if 9 we have to prepend current unit to next return cls.__mappings[index][1] + cls.__mappings[index + 1][1] @classmethod def encode(cls, input_number: Union[str, int]) -> str: # force input conversion to a string (we need it in order to iterate on each digit) input_string = str(input_number) if not is_integer(input_string): raise ValueError('Invalid input, only strings or integers are allowed') value = int(input_string) if value < 1 or value > 3999: raise ValueError('Input must be >= 1 and <= 3999') input_len = len(input_string) output = '' # decode digits from right to left (start from units to thousands) for index in range(input_len): # get actual digit value as int digit = int(input_string[input_len - index - 1]) # encode digit to roman string encoded_digit = cls.__encode_digit(index, digit) # prepend encoded value to the current output in order to have the final string sorted # from thousands to units output = encoded_digit + output return output @classmethod def __index_for_sign(cls, sign: str) -> int: for index, mapping in enumerate(cls.__reversed_mappings): if sign in mapping: return index raise ValueError('Invalid token found: "{}"'.format(sign)) @classmethod def decode(cls, input_string: str) -> int: if not is_full_string(input_string): raise ValueError('Input must be a non empty string') # reverse the provided string so that we can start parsing from units to thousands reversed_string = reverse(input_string.upper()) # track last used value last_value = None # computed number to return output = 0 # for each sign in the string we get its numeric value and add or subtract it to the computed output for sign in reversed_string: # are we dealing with units, tens, hundreds or thousands? index = cls.__index_for_sign(sign) # it's basically 1 or 5 (based on mapping rules definitions) key_value = cls.__reversed_mappings[index][sign] # Based on the level (tens, hundreds...) we have to add as many zeroes as the level into which we are # in order to have the actual sign value. # For instance, if we are at level 2 we are dealing with hundreds, therefore instead of 1 or 5, we will # obtain 100 or 500 by adding 2 zeroes sign_value = int(str(key_value) + '0' * index) # increase total value if we are moving on with level if last_value is None or sign_value >= last_value: output += sign_value # Decrease value if we are back to a previous level # For instance, if we are parsing "IX", we first encounter "X" which is ten then "I" which is unit, # So we have to do the following operation in order to get 9 (the final result): 10 - 1 else: output -= sign_value last_value = sign_value return output class __StringCompressor: @staticmethod def __require_valid_input_and_encoding(input_string: str, encoding: str): if not is_string(input_string): raise InvalidInputError(input_string) if len(input_string) == 0: raise ValueError('Input string cannot be empty') if not is_string(encoding): raise ValueError('Invalid encoding') @classmethod def compress(cls, input_string: str, encoding: str = 'utf-8', compression_level: int = 9) -> str: cls.__require_valid_input_and_encoding(input_string, encoding) if not isinstance(compression_level, int) or compression_level < 0 or compression_level > 9: raise ValueError('Invalid compression_level: it must be an "int" between 0 and 9') # turns input string into a sequence of bytes using provided encoding original_bytes = input_string.encode(encoding) # compress bytes using zlib library compressed_bytes = zlib.compress(original_bytes, compression_level) # encode compressed bytes using base64 # (this ensure that all characters will be available and that the output string can be used safely in any # context such URLs) encoded_bytes = base64.urlsafe_b64encode(compressed_bytes) # finally turns base64 bytes into a string output = encoded_bytes.decode(encoding) return output @classmethod def decompress(cls, input_string: str, encoding: str = 'utf-8') -> str: cls.__require_valid_input_and_encoding(input_string, encoding) # turns input string into a sequence of bytes # (the string is assumed to be a previously compressed string, therefore we have to decode it using base64) input_bytes = base64.urlsafe_b64decode(input_string) # decompress bytes using zlib decompressed_bytes = zlib.decompress(input_bytes) # decode the decompressed bytes to get the original string back original_string = decompressed_bytes.decode(encoding) return original_string class __StringFormatter: def __init__(self, input_string): if not is_string(input_string): raise InvalidInputError(input_string) self.input_string = input_string def __uppercase_first_char(self, regex_match): return regex_match.group(0).upper() def __remove_duplicates(self, regex_match): return regex_match.group(1)[0] def __uppercase_first_letter_after_sign(self, regex_match): match = regex_match.group(1) return match[:-1] + match[2].upper() def __ensure_right_space_only(self, regex_match): return regex_match.group(1).strip() + ' ' def __ensure_left_space_only(self, regex_match): return ' ' + regex_match.group(1).strip() def __ensure_spaces_around(self, regex_match): return ' ' + regex_match.group(1).strip() + ' ' def __remove_internal_spaces(self, regex_match): return regex_match.group(1).strip() def __fix_saxon_genitive(self, regex_match): return regex_match.group(1).replace(' ', '') + ' ' # generates a placeholder to inject temporary into the string, it will be replaced with the original # value at the end of the process @staticmethod def __placeholder_key(): return '$' + uuid4().hex + '$' def format(self) -> str: # map of temporary placeholders placeholders = {} out = self.input_string # looks for url or email and updates placeholders map with found values placeholders.update({self.__placeholder_key(): m[0] for m in URLS_RE.findall(out)}) placeholders.update({self.__placeholder_key(): m for m in EMAILS_RE.findall(out)}) # replace original value with the placeholder key for p in placeholders: out = out.replace(placeholders[p], p, 1) out = PRETTIFY_RE['UPPERCASE_FIRST_LETTER'].sub(self.__uppercase_first_char, out) out = PRETTIFY_RE['DUPLICATES'].sub(self.__remove_duplicates, out) out = PRETTIFY_RE['RIGHT_SPACE'].sub(self.__ensure_right_space_only, out) out = PRETTIFY_RE['LEFT_SPACE'].sub(self.__ensure_left_space_only, out) out = PRETTIFY_RE['SPACES_AROUND'].sub(self.__ensure_spaces_around, out) out = PRETTIFY_RE['SPACES_INSIDE'].sub(self.__remove_internal_spaces, out) out = PRETTIFY_RE['UPPERCASE_AFTER_SIGN'].sub(self.__uppercase_first_letter_after_sign, out) out = PRETTIFY_RE['SAXON_GENITIVE'].sub(self.__fix_saxon_genitive, out) out = out.strip() # restore placeholder keys with their associated original value for p in placeholders: out = out.replace(p, placeholders[p], 1) return out def reverse(input_string: str) -> str: """ Returns the string with its chars reversed. *Example:* >>> reverse('hello') # returns 'olleh' :param input_string: String to revert. :type input_string: str :return: Reversed string. """ if not is_string(input_string): raise InvalidInputError(input_string) return input_string[::-1] def camel_case_to_snake(input_string, separator='_'): """ Convert a camel case string into a snake case one. (The original string is returned if is not a valid camel case string) *Example:* >>> camel_case_to_snake('ThisIsACamelStringTest') # returns 'this_is_a_camel_case_string_test' :param input_string: String to convert. :type input_string: str :param separator: Sign to use as separator. :type separator: str :return: Converted string. """ if not is_string(input_string): raise InvalidInputError(input_string) if not is_camel_case(input_string): return input_string return CAMEL_CASE_REPLACE_RE.sub(lambda m: m.group(1) + separator, input_string).lower() def snake_case_to_camel(input_string: str, upper_case_first: bool = True, separator: str = '_') -> str: """ Convert a snake case string into a camel case one. (The original string is returned if is not a valid snake case string) *Example:* >>> snake_case_to_camel('the_snake_is_green') # returns 'TheSnakeIsGreen' :param input_string: String to convert. :type input_string: str :param upper_case_first: True to turn the first letter into uppercase (default). :type upper_case_first: bool :param separator: Sign to use as separator (default to "_"). :type separator: str :return: Converted string """ if not is_string(input_string): raise InvalidInputError(input_string) if not is_snake_case(input_string, separator): return input_string tokens = [s.title() for s in input_string.split(separator) if is_full_string(s)] if not upper_case_first: tokens[0] = tokens[0].lower() out = ''.join(tokens) return out def shuffle(input_string: str) -> str: """ Return a new string containing same chars of the given one but in a randomized order. *Example:* >>> shuffle('hello world') # possible output: 'l wodheorll' :param input_string: String to shuffle :type input_string: str :return: Shuffled string """ if not is_string(input_string): raise InvalidInputError(input_string) # turn the string into a list of chars chars = list(input_string) # shuffle the list random.shuffle(chars) # convert the shuffled list back to string return ''.join(chars) def strip_html(input_string: str, keep_tag_content: bool = False) -> str: """ Remove html code contained into the given string. *Examples:* >>> strip_html('test: <a href="foo/bar">click here</a>') # returns 'test: ' >>> strip_html('test: <a href="foo/bar">click here</a>', keep_tag_content=True) # returns 'test: click here' :param input_string: String to manipulate. :type input_string: str :param keep_tag_content: True to preserve tag content, False to remove tag and its content too (default). :type keep_tag_content: bool :return: String with html removed. """ if not is_string(input_string): raise InvalidInputError(input_string) r = HTML_TAG_ONLY_RE if keep_tag_content else HTML_RE return r.sub('', input_string) def prettify(input_string: str) -> str: """ Reformat a string by applying the following basic grammar and formatting rules: - String cannot start or end with spaces - The first letter in the string and the ones after a dot, an exclamation or a question mark must be uppercase - String cannot have multiple sequential spaces, empty lines or punctuation (except for "?", "!" and ".") - Arithmetic operators (+, -, /, \\*, =) must have one, and only one space before and after themselves - One, and only one space should follow a dot, a comma, an exclamation or a question mark - Text inside double quotes cannot start or end with spaces, but one, and only one space must come first and \ after quotes (foo" bar"baz -> foo "bar" baz) - Text inside round brackets cannot start or end with spaces, but one, and only one space must come first and \ after brackets ("foo(bar )baz" -> "foo (bar) baz") - Percentage sign ("%") cannot be preceded by a space if there is a number before ("100 %" -> "100%") - Saxon genitive is correct ("Dave' s dog" -> "Dave's dog") *Examples:* >>> prettify(' unprettified string ,, like this one,will be"prettified" .it\\' s awesome! ') >>> # -> 'Unprettified string, like this one, will be "prettified". It\'s awesome!' :param input_string: String to manipulate :return: Prettified string. """ formatted = __StringFormatter(input_string).format() return formatted def asciify(input_string: str) -> str: """ Force string content to be ascii-only by translating all non-ascii chars into the closest possible representation (eg: ó -> o, Ë -> E, ç -> c...). **Bear in mind**: Some chars may be lost if impossible to translate. *Example:* >>> asciify('èéùúòóäåëýñÅÀÁÇÌÍÑÓË') # returns 'eeuuooaaeynAAACIINOE' :param input_string: String to convert :return: Ascii utf-8 string """ if not is_string(input_string): raise InvalidInputError(input_string) # "NFKD" is the algorithm which is able to successfully translate the most of non-ascii chars normalized = unicodedata.normalize('NFKD', input_string) # encode string forcing ascii and ignore any errors (unrepresentable chars will be stripped out) ascii_bytes = normalized.encode('ascii', 'ignore') # turns encoded bytes into an utf-8 string ascii_string = ascii_bytes.decode('utf-8') return ascii_string def slugify(input_string: str, separator: str = '-') -> str: """ Converts a string into a "slug" using provided separator. The returned string has the following properties: - it has no spaces - all letters are in lower case - all punctuation signs and non alphanumeric chars are removed - words are divided using provided separator - all chars are encoded as ascii (by using `asciify()`) - is safe for URL *Examples:* >>> slugify('Top 10 Reasons To Love Dogs!!!') # returns: 'top-10-reasons-to-love-dogs' >>> slugify('Mönstér Mägnët') # returns 'monster-magnet' :param input_string: String to convert. :type input_string: str :param separator: Sign used to join string tokens (default to "-"). :type separator: str :return: Slug string """ if not is_string(input_string): raise InvalidInputError(input_string) # replace any character that is NOT letter or number with spaces out = NO_LETTERS_OR_NUMBERS_RE.sub(' ', input_string.lower()).strip() # replace spaces with join sign out = SPACES_RE.sub(separator, out) # normalize joins (remove duplicates) out = re.sub(re.escape(separator) + r'+', separator, out) return asciify(out) def booleanize(input_string: str) -> bool: """ Turns a string into a boolean based on its content (CASE INSENSITIVE). A positive boolean (True) is returned if the string value is one of the following: - "true" - "1" - "yes" - "y" Otherwise False is returned. *Examples:* >>> booleanize('true') # returns True >>> booleanize('YES') # returns True >>> booleanize('nope') # returns False :param input_string: String to convert :type input_string: str :return: True if the string contains a boolean-like positive value, false otherwise """ if not is_string(input_string): raise InvalidInputError(input_string) return input_string.lower() in ('true', '1', 'yes', 'y') def strip_margin(input_string: str) -> str: """ Removes tab indentation from multi line strings (inspired by analogous Scala function). *Example:* >>> strip_margin(''' >>> line 1 >>> line 2 >>> line 3 >>> ''') >>> # returns: >>> ''' >>> line 1 >>> line 2 >>> line 3 >>> ''' :param input_string: String to format :type input_string: str :return: A string without left margins """ if not is_string(input_string): raise InvalidInputError(input_string) line_separator = '\n' lines = [MARGIN_RE.sub('', line) for line in input_string.split(line_separator)] out = line_separator.join(lines) return out def compress(input_string: str, encoding: str = 'utf-8', compression_level: int = 9) -> str: """ Compress the given string by returning a shorter one that can be safely used in any context (like URL) and restored back to its original state using `decompress()`. **Bear in mind:** Besides the provided `compression_level`, the compression result (how much the string is actually compressed by resulting into a shorter string) depends on 2 factors: 1. The amount of data (string size): short strings might not provide a significant compression result\ or even be longer than the given input string (this is due to the fact that some bytes have to be embedded\ into the compressed string in order to be able to restore it later on)\ 2. The content type: random sequences of chars are very unlikely to be successfully compressed, while the best\ compression result is obtained when the string contains several recurring char sequences (like in the example). Behind the scenes this method makes use of the standard Python's zlib and base64 libraries. *Examples:* >>> n = 0 # <- ignore this, it's a fix for Pycharm (not fixable using ignore comments) >>> # "original" will be a string with 169 chars: >>> original = ' '.join(['word n{}'.format(n) for n in range(20)]) >>> # "compressed" will be a string of 88 chars >>> compressed = compress(original) :param input_string: String to compress (must be not empty or a ValueError will be raised). :type input_string: str :param encoding: String encoding (default to "utf-8"). :type encoding: str :param compression_level: A value between 0 (no compression) and 9 (best compression), default to 9. :type compression_level: int :return: Compressed string. """ return __StringCompressor.compress(input_string, encoding, compression_level) def decompress(input_string: str, encoding: str = 'utf-8') -> str: """ Restore a previously compressed string (obtained using `compress()`) back to its original state. :param input_string: String to restore. :type input_string: str :param encoding: Original string encoding. :type encoding: str :return: Decompressed string. """ return __StringCompressor.decompress(input_string, encoding) def roman_encode(input_number: Union[str, int]) -> str: """ Convert the given number/string into a roman number. The passed input must represents a positive integer in the range 1-3999 (inclusive). Why this limit? You may be wondering: 1. zero is forbidden since there is no related representation in roman numbers 2. the upper bound 3999 is due to the limitation in the ascii charset\ (the higher quantity sign displayable in ascii is "M" which is equal to 1000, therefore based on\ roman numbers rules we can use 3 times M to reach 3000 but we can't go any further in thousands without\ special "boxed chars"). *Examples:* >>> roman_encode(37) # returns 'XXXVIII' >>> roman_encode('2020') # returns 'MMXX' :param input_number: An integer or a string to be converted. :type input_number: Union[str, int] :return: Roman number string. """ return __RomanNumbers.encode(input_number) def roman_decode(input_string: str) -> int: """ Decode a roman number string into an integer if the provided string is valid. *Example:* >>> roman_decode('VII') # returns 7 :param input_string: (Assumed) Roman number :type input_string: str :return: Integer value """ return __RomanNumbers.decode(input_string) import pickle def test_0(): assert camel_case_to_snake("MySuperCamelCaseString") == "my_super_camel_case_string" test_0() def test_1(): assert camel_case_to_snake('') == '' test_1() def test_2(): assert camel_case_to_snake('this_is_not_a_camel_case_string_test') == 'this_is_not_a_camel_case_string_test' test_2() def test_3(): assert camel_case_to_snake('123') == '123' test_3() def test_5(): assert camel_case_to_snake("Case") == "case" test_5() def test_7(): assert camel_case_to_snake('ThisIsACamelCaseStringTest') == 'this_is_a_camel_case_string_test' test_7() def test_8(): assert camel_case_to_snake('this_is_snake') == 'this_is_snake' test_8() def test_9(): assert camel_case_to_snake('ThisIsNotACamelStringTest') == 'this_is_not_a_camel_string_test' test_9() def test_10(): assert camel_case_to_snake('This') == 'this' test_10() def test_15(): assert camel_case_to_snake('aB2def') == 'a_b2def' test_15() def test_17(): assert camel_case_to_snake('aBc1def') == 'a_bc1def' test_17() def test_20(): assert camel_case_to_snake('test2case234') == 'test2case234' test_20() def test_21(): assert camel_case_to_snake("camelCaseString") == "camel_case_string" test_21() def test_22(): assert camel_case_to_snake('camel123') == 'camel123' test_22() def test_23(): assert camel_case_to_snake('ACamelString') == 'a_camel_string' test_23() def test_26(): assert camel_case_to_snake("one2three4") == "one2three4" test_26() def test_30(): assert camel_case_to_snake('TestCase234') == 'test_case234' test_30() def test_32(): assert camel_case_to_snake("ThisIsACamelCaseString") == "this_is_a_camel_case_string" test_32() def test_33(): assert camel_case_to_snake('this_is_a_camel_case_string_test') == 'this_is_a_camel_case_string_test' test_33() def test_35(): assert camel_case_to_snake('1') == '1' test_35() def test_39(): assert camel_case_to_snake('thisIsATestString') == 'this_is_a_test_string' test_39() def test_41(): assert camel_case_to_snake('ThisIsCamelCase') == 'this_is_camel_case' test_41() def test_43(): assert camel_case_to_snake('ThisIsACamelCaseStringTest12') == 'this_is_a_camel_case_string_test12' test_43() def test_44(): assert camel_case_to_snake('thisIsACamelCaseStringTest', '*') == 'this*is*a*camel*case*string*test' test_44() def test_46(): assert camel_case_to_snake('testCase') == 'test_case' test_46() def test_47(): assert camel_case_to_snake('thisIs') == 'this_is' test_47() def test_48(): assert camel_case_to_snake("") == '' test_48() def test_51(): assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest123') == 'this_is_also_not_a_camel_case_string_test123' test_51() def test_54(): assert camel_case_to_snake('this_is_a_camel_case_string_test_with_underscores') == 'this_is_a_camel_case_string_test_with_underscores' test_54() def test_59(): assert camel_case_to_snake('AnotherTest') == 'another_test' test_59() def test_62(): assert camel_case_to_snake("ACamelCaseString") == "a_camel_case_string" test_62() def test_63(): assert camel_case_to_snake('TestCase2') == 'test_case2' test_63() def test_64(): assert camel_case_to_snake('this_is_not_a_camel_case_string') == 'this_is_not_a_camel_case_string' test_64() def test_65(): assert camel_case_to_snake('ThisIsACamelStringTest', '') == 'thisisacamelstringtest' test_65() def test_68(): assert camel_case_to_snake('MyString') == 'my_string' test_68() def test_71(): assert camel_case_to_snake('ThisIsACamelStringTest', '...') == 'this...is...a...camel...string...test' test_71() def test_72(): assert camel_case_to_snake("CCamelCase") == "c_camel_case" test_72() def test_73(): assert camel_case_to_snake('CamelCaseToSnakeWithNumber1') == 'camel_case_to_snake_with_number1' test_73() def test_74(): assert camel_case_to_snake('ThisIsCamelCaseWithNumber123') == 'this_is_camel_case_with_number123' test_74() def test_75(): assert camel_case_to_snake('ThisIsAnotherCamelStringTest') == 'this_is_another_camel_string_test' test_75() def test_77(): assert camel_case_to_snake('Test') == 'test' test_77() def test_78(): assert camel_case_to_snake('123camel') == '123camel' test_78() def test_79(): assert camel_case_to_snake('AaBbCc') == 'aa_bb_cc' test_79() def test_80(): assert camel_case_to_snake('this_is_a_snake_case_string_test') == 'this_is_a_snake_case_string_test' test_80() def test_81(): assert camel_case_to_snake('CamelStringTest') == 'camel_string_test' test_81() def test_82(): assert camel_case_to_snake('ThisIsACamelStringTest', '-') == 'this-is-a-camel-string-test' test_82() def test_85(): assert camel_case_to_snake('ThisIsAReallyVeryVeryLongCamelCaseStringTest') == 'this_is_a_really_very_very_long_camel_case_string_test' test_85() def test_87(): assert camel_case_to_snake('ThisIsAnotherCamelCase') == 'this_is_another_camel_case' test_87() def test_89(): assert camel_case_to_snake("ThisIsACamelCaseStringTest") == 'this_is_a_camel_case_string_test' test_89() def test_91(): assert camel_case_to_snake("MyString") == "my_string" test_91() def test_92(): assert camel_case_to_snake('ThisIsACamelCaseStringTest1') == 'this_is_a_camel_case_string_test1' test_92() def test_96(): assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest12345') == 'this_is_also_not_a_camel_case_string_test12345' test_96() def test_97(): assert camel_case_to_snake('CamelCaseToSnake') == 'camel_case_to_snake' test_97() def test_98(): assert camel_case_to_snake("ThisIsACamelStringTest") == "this_is_a_camel_string_test" test_98() def test_100(): assert camel_case_to_snake('my_string_test') == 'my_string_test' test_100() def test_101(): assert camel_case_to_snake('thisIsAnotherCamel') == 'this_is_another_camel' test_101() def test_103(): assert camel_case_to_snake('this_is_not_a_camel_string_test') == 'this_is_not_a_camel_string_test' test_103() def test_104(): assert camel_case_to_snake("CamelCaseString") == "camel_case_string" test_104() def test_106(): assert camel_case_to_snake('TestCase') == 'test_case' test_106() def test_109(): assert camel_case_to_snake('ThisIsACamel') == 'this_is_a_camel' test_109() def test_110(): assert camel_case_to_snake('ThisIsACamelCaseStringTest123') == 'this_is_a_camel_case_string_test123' test_110() def test_113(): assert camel_case_to_snake("CaseString") == "case_string" test_113() def test_114(): assert camel_case_to_snake('ThisIsACamelCaseString') == 'this_is_a_camel_case_string' test_114() def test_115(): assert camel_case_to_snake('ThisIsCamel') == 'this_is_camel' test_115() def test_116(): assert camel_case_to_snake('ThisIsATestString') == 'this_is_a_test_string' test_116() def test_117(): assert camel_case_to_snake('abc1def') == 'abc1def' test_117() def test_118(): assert camel_case_to_snake('ThisIsACamelCaseString987') == 'this_is_a_camel_case_string987' test_118() def test_121(): assert camel_case_to_snake('ThisIsaCamelCaseString') == 'this_isa_camel_case_string' test_121() def test_122(): assert camel_case_to_snake('aB') == 'a_b' test_122() def test_123(): assert camel_case_to_snake('testCase2') == 'test_case2' test_123() def test_124(): assert camel_case_to_snake("MyCamelCaseString") == "my_camel_case_string" test_124() def test_125(): assert camel_case_to_snake('CamelCase') == 'camel_case' test_125() def test_126(): assert camel_case_to_snake("Camel") == "camel" test_126() def test_127(): assert camel_case_to_snake("thisIsACamelCaseStringTest") == "this_is_a_camel_case_string_test" test_127() def test_128(): assert camel_case_to_snake('ThisIsATestForLowerCase') == 'this_is_a_test_for_lower_case' test_128() def test_129(): assert camel_case_to_snake('ThisIsACamelStringTest', '_') == 'this_is_a_camel_string_test' test_129() def test_131(): assert camel_case_to_snake('ThisIsAStringTest') == 'this_is_a_string_test' test_131() def test_132(): assert camel_case_to_snake('ThisIsACamelStringTest') == 'this_is_a_camel_string_test' test_132() def test_133(): assert camel_case_to_snake('ThisIsAlsoNotACamelCaseStringTest') == 'this_is_also_not_a_camel_case_string_test' test_133() def test_134(): assert camel_case_to_snake('thisIsACamelCaseStringTest') == 'this_is_a_camel_case_string_test' test_134() def test_135(): assert camel_case_to_snake('thisIsCamel') == 'this_is_camel' test_135() def test_138(): assert camel_case_to_snake('ab2def') == 'ab2def' test_138() def test_140(): assert camel_case_to_snake('thisIsACamelStringTest') == 'this_is_a_camel_string_test' test_140() def test_143(): assert camel_case_to_snake('camelCase') == 'camel_case' test_143() def test_145(): assert camel_case_to_snake('ThisIsCamelCaseStringTest') == 'this_is_camel_case_string_test' test_145() def test_146(): assert camel_case_to_snake("MySuperCamelCaseString", "@") == "my@super@camel@case@string" test_146() def test_147(): assert camel_case_to_snake('thisIsACamelCaseStringTest', '+') == 'this+is+a+camel+case+string+test' test_147() def test_149(): assert camel_case_to_snake("HelloWorld") == 'hello_world' test_149() def test_151(): assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == 'this is a camel string test' test_151() def test_152(): assert camel_case_to_snake('this') == 'this' test_152() def test_153(): assert camel_case_to_snake('TeSt') == 'te_st' test_153() def test_154(): assert camel_case_to_snake("CamelCase") == "camel_case" test_154() def test_156(): assert camel_case_to_snake('AnotherCamelStringTest') == 'another_camel_string_test' test_156() def test_159(): assert camel_case_to_snake("aAaA") == "a_aa_a" test_159() def test_4(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_4", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('AB') == output test_4() def test_6(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_6", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('test2Case234') == output test_6() def test_11(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_11", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output test_11() def test_12(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_12", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMelCaseString") == output test_12() def test_13(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_13", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsNotACamelCaseString') == output test_13() def test_14(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_14", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelString_Test') == output test_14() def test_16(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_16", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelCaseString123TestABC') == output test_16() def test_18(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_18", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("One2Three4") == output test_18() def test_19(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_19", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("mySuperCamelCaseString") == output test_19() def test_24(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_24", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', '.') == output test_24() def test_25(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_25", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("ThisIsA_CAMELCaseStringTest_Test") == output test_25() def test_27(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_27", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output test_27() def test_28(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_28", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('This_Is_A_Camel_Case_String_Test') == output test_28() def test_29(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_29", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('_ThisIsACamelStringTest') == output test_29() def test_31(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_31", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamel2StringTest') == output test_31() def test_34(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_34", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('This_Is_A_Camel_Case_String_123Test') == output test_34() def test_36(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_36", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('Test2Case234') == output test_36() def test_37(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_37", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('test1Case') == output test_37() def test_38(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_38", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('1A') == output test_38() def test_40(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_40", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('A1') == output test_40() def test_42(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_42", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsAnotherCamelCaseStringTest') == output test_42() def test_45(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_45", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('This_is_not_a_camel_case_string_test') == output test_45() def test_49(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_49", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('T') == output test_49() def test_50(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_50", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('THISISSHOUTCASE') == output test_50() def test_52(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_52", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelCaseString123Test123') == output test_52() def test_53(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_53", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('TestTEST') == output test_53() def test_55(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_55", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelCaseString123Test') == output test_55() def test_56(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_56", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMELCaseStringTest_Test") == output test_56() def test_57(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_57", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('TEST') == output test_57() def test_58(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_58", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelString2Test') == output test_58() def test_60(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_60", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('A1B') == output test_60() def test_61(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_61", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamelStringTest') == output test_61() def test_66(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_66", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("One2Three") == output test_66() def test_67(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_67", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamelString2Test') == output test_67() def test_69(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_69", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsA2CamelStringTest') == output test_69() def test_70(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_70", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMELCaseString") == output test_70() def test_76(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_76", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("A1B2C3") == output test_76() def test_83(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_83", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTestWithoutSeparator', '') == output test_83() def test_84(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_84", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('THIS_IS_NOT_A_CAMEL_CASE_STRING_TEST') == output test_84() def test_86(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_86", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CamelCaseString") == output test_86() def test_88(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_88", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('this_Is_a_CaMel_case_String_Test') == output test_88() def test_90(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_90", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTestWithDigits123') == output test_90() def test_93(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_93", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs_CamelCase') == output test_93() def test_94(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_94", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('123thisIsNotAString') == output test_94() def test_95(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_95", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTestWithoutSeparator') == output test_95() def test_99(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_99", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest') == output test_99() def test_102(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_102", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamel2StringTest') == output test_102() def test_105(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_105", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output test_105() def test_107(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_107", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('thisIsNotACamelStringTest') == output test_107() def test_108(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_108", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelString') == output test_108() def test_111(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_111", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsSnake_Case') == output test_111() def test_112(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_112", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('345thisIsNotAString') == output test_112() def test_119(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_119", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CAMELCaseStringTest") == output test_119() def test_120(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_120", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', ' ') == output test_120() def test_130(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_130", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('thisIsNotAString') == output test_130() def test_136(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_136", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CamelCaseString_Test") == output test_136() def test_137(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_137", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIs2ACamel2String2Test') == output test_137() def test_139(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_139", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('tHISiS_a_CaMel_CASE_sTrinG_TEST') == output test_139() def test_141(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_141", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsaCamelString') == output test_141() def test_142(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_142", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', '-') == output test_142() def test_144(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_144", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('thisIsACamelStringTest') == output test_144() def test_148(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_148", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('TEST2test') == output test_148() def test_150(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_150", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('THISiS_a_CaMel_CASE_sTrinG_TEST') == output test_150() def test_155(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_155", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsAnotherCamelStringTest') == output test_155() def test_157(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_157", "rb") as f: output = pickle.load(f) assert camel_case_to_snake("thisIsA_CamelCaseStringTest") == output test_157() def test_158(): with open("/output/test-apps+python-string-utils/test_output/string_utils+manipulation/camel_case_to_snake/test_158", "rb") as f: output = pickle.load(f) assert camel_case_to_snake('ThisIsACamelStringTest', separator='') == output test_158()
true
false
80
2
test-apps/python-string-utils
string_utils.manipulation
snake_case_to_camel
"def snake_case_to_camel(input_string: str, upper_case_first: bool = True, separator: str = '_') -> (...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def snake_case_to_camel(input_string: str, upper_case_first: bool = True, separator: str = '_') -> (...TRUNCATED)
"def snake_case_to_camel(input_string: str, upper_case_first: bool = True, separator: str = '_') -> (...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_0():\n assert snake_case_to_camel('foo_bar_(...TRUNCATED)
"\nConvert a snake case string into a camel case one.\n(The original string is returned if is not a (...TRUNCATED)
"\"\"\"\nConvert a snake case string into a camel case one.\n(The original string is returned if is (...TRUNCATED)
["Convert","a","snake","case","string","into","a","camel","case","one",".","(","The","original","str(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
true
false
88.888885
4
test-apps/python-string-utils
string_utils.manipulation
strip_html
"def strip_html(input_string: str, keep_tag_content: bool = False) -> str:\n \"\"\"\n Remove h(...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def strip_html(input_string: str, keep_tag_content: bool = False) -> str:\n \"\"\"\n Remove h(...TRUNCATED)
def strip_html(input_string: str, keep_tag_content: bool = False) -> str:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_1():\n assert is_string(strip_html('<a href(...TRUNCATED)
"\nRemove html code contained into the given string.\n\n*Examples:*\n\n>>> strip_html('test: <a href(...TRUNCATED)
"\"\"\"\nRemove html code contained into the given string.\n\n*Examples:*\n\n>>> strip_html('test: <(...TRUNCATED)
["Remove","html","code","contained","into","the","given","string",".","*","Examples",":","*",">>>","(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
true
false
75
5
test-apps/python-string-utils
string_utils.manipulation
prettify
"def prettify(input_string: str) -> str:\n \"\"\"\n Reformat a string by applying the followin(...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def prettify(input_string: str) -> str:\n \"\"\"\n Reformat a string by applying the followin(...TRUNCATED)
def prettify(input_string: str) -> str:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_1():\n assert prettify(\"unprettified strin(...TRUNCATED)
"\nReformat a string by applying the following basic grammar and formatting rules:\n\n- String canno(...TRUNCATED)
"\"\"\"\nReformat a string by applying the following basic grammar and formatting rules:\n\n- String(...TRUNCATED)
["Reformat","a","string","by","applying","the","following","basic","grammar","and","formatting","rul(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
false
false
100
6
test-apps/python-string-utils
string_utils.manipulation
asciify
"def asciify(input_string: str) -> str:\n \"\"\"\n Force string content to be ascii-only by tr(...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def asciify(input_string: str) -> str:\n \"\"\"\n Force string content to be ascii-only by tr(...TRUNCATED)
def asciify(input_string: str) -> str:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_1():\n assert not is_string(asciify('ààè(...TRUNCATED)
"\nForce string content to be ascii-only by translating all non-ascii chars into the closest possibl(...TRUNCATED)
"\"\"\"\nForce string content to be ascii-only by translating all non-ascii chars into the closest p(...TRUNCATED)
["Force","string","content","to","be","ascii","-","only","by","translating","all","non","-","ascii",(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
true
true
83.333336
7
test-apps/python-string-utils
string_utils.manipulation
slugify
"def slugify(input_string: str, separator: str = '-') -> str:\n \"\"\"\n Converts a string int(...TRUNCATED)
"import re\nimport base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\(...TRUNCATED)
"def slugify(input_string: str, separator: str = '-') -> str:\n \"\"\"\n Converts a string int(...TRUNCATED)
def slugify(input_string: str, separator: str = '-') -> str:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_2():\n assert slugify('This is another test(...TRUNCATED)
"\nConverts a string into a \"slug\" using provided separator.\nThe returned string has the followin(...TRUNCATED)
"\"\"\"\nConverts a string into a \"slug\" using provided separator.\nThe returned string has the fo(...TRUNCATED)
["Converts","a","string","into","a","\"","slug","\"","using","provided","separator",".","The","retur(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
true
false
83.333336
8
test-apps/python-string-utils
string_utils.manipulation
booleanize
"def booleanize(input_string: str) -> bool:\n \"\"\"\n Turns a string into a boolean based on (...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def booleanize(input_string: str) -> bool:\n \"\"\"\n Turns a string into a boolean based on (...TRUNCATED)
def booleanize(input_string: str) -> bool:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_0():\n assert booleanize('n') == False","@t(...TRUNCATED)
"\nTurns a string into a boolean based on its content (CASE INSENSITIVE).\n\nA positive boolean (Tru(...TRUNCATED)
"\"\"\"\nTurns a string into a boolean based on its content (CASE INSENSITIVE).\n\nA positive boolea(...TRUNCATED)
["Turns","a","string","into","a","boolean","based","on","its","content","(","CASE","INSENSITIVE",")"(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
true
false
66.666664
9
test-apps/python-string-utils
string_utils.manipulation
strip_margin
"def strip_margin(input_string: str) -> str:\n \"\"\"\n Removes tab indentation from multi lin(...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def strip_margin(input_string: str) -> str:\n \"\"\"\n Removes tab indentation from multi lin(...TRUNCATED)
def strip_margin(input_string: str) -> str:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_0():\n assert strip_margin('''\n (...TRUNCATED)
"\nRemoves tab indentation from multi line strings (inspired by analogous Scala function).\n\n*Examp(...TRUNCATED)
"\"\"\"\nRemoves tab indentation from multi line strings (inspired by analogous Scala function).\n\n(...TRUNCATED)
["Removes","tab","indentation","from","multi","line","strings","(","inspired","by","analogous","Scal(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
true
false
83.333336
10
test-apps/python-string-utils
string_utils.manipulation
decompress
"def decompress(input_string: str, encoding: str = 'utf-8') -> str:\n \"\"\"\n Restore a previ(...TRUNCATED)
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
"def decompress(input_string: str, encoding: str = 'utf-8') -> str:\n \"\"\"\n Restore a previ(...TRUNCATED)
def decompress(input_string: str, encoding: str = 'utf-8') -> str:
"import base64\nimport random\nimport unicodedata\nimport zlib\nfrom typing import Union\nfrom uuid (...TRUNCATED)
["@timeout_decorator.timeout(LOCAL_TIMEOUT)\ndef test_1():\n assert \" a\" == decompress(compress(...TRUNCATED)
"\nRestore a previously compressed string (obtained using `compress()`) back to its original state.\(...TRUNCATED)
"\"\"\"\nRestore a previously compressed string (obtained using `compress()`) back to its original s(...TRUNCATED)
["Restore","a","previously","compressed","string","(","obtained","using","`","compress","()","`",")"(...TRUNCATED)
"\nimport sys\nsys.path.insert(1, \"/input/test-apps/python-string-utils\")\nimport unittest, pytest(...TRUNCATED)
false
false
100

Dataset Card for "RepoCodeGen"

More Information needed

Downloads last month
44
Edit dataset card