<jupyter_start><jupyter_text>Негативные тесты<jupyter_code>def test_list_1():
    try:
        assert l[len(l)] 
    except IndexError:
        print("list index out of range")
test_list_1()
def add_char_in_string(c):
    S[0] = c

    
def test_string_1():
    try:
        assert add_char_in_string('c')
    except TypeError:
        print("str object does not support item assignment")
test_string_1()<jupyter_output>str object does not support item assignment<jupyter_text>Обычные тесты<jupyter_code>def sum_list(x):
    sum_ = 0
    for elem in x:
        sum_ += elem
    return sum_

def test_list_2():
    assert (16 == sum_list([1,3,5,7]))
    assert (4 == sum_list([4]))
    assert (0 == sum_list([]))
    print("Test Passed")
test_list_2()
def add_char(s):
    s += '.'
    return s

def test_string_2():
    assert ('.' == add_char(''))
    assert ('Abc.' == add_char('Abc'))
    assert ('Xyz...' == add_char('Xyz..'))
    print("Test Passed")
 test_string_2()<jupyter_output>Test Passed<jupyter_text>Параметризованные тесты<jupyter_code>def string_func(s):
    if len(s) > 6:
        return s + "!"
    elif len(s) < 6:
        return s + "?"
    else:
        return s + "..."
def test_string_3(tests):
    for answer, data in tests:
        assert (answer == string_func(data))
    print("Test Passed")
tests = [('Mail.ru!', 'Mail.ru'),
         ('Yandex...', 'Yandex'),
         ('Intel?', 'Intel')]
test_string_3(tests)
def list_func(l):
    if len(l) > 3:
        l.append("More than three")
        return l
    elif len(l) < 3:
        l.append("Less than three")
        return l
    else:
        l.append("Equal to three")
        return l
def test_list_3(tests):
    for answer, data in tests:
        assert (answer == list_func(data))
    print("Test Passed")
tests = [([1,'b', 4, 5,"More than three"], [1,'b',4,5]),
         ([1,'b', "Less than three"], [1,'b']),
        ([1,'b',4,"Equal to three"], [1,'b',4])]
test_list_3(tests)<jupyter_output>Test Passed
{'fraction_non_alphanumeric': 0.1672544080604534, 'fraction_numerical': 0.01964735516372796, 'mean_word_length': 2.94831013916501, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '37157', 'license': 'Unlicense', 'n_tokens_mistral': 752, 'n_tokens_neox': 739, 'n_words': 173, 'path': 'Mail_auth_test.ipynb', 'repo_name': 'successful-try/study', 'size': '1985'}