<commit_before>import re
from cassandra import InvalidRequest, Unavailable, ConsistencyLevel
from cassandra.query import SimpleStatement
from cassandra.protocol import SyntaxException
from pytools import rows_to_list

def assert_unavailable(fun, *args):
    try:
        if len(args) == 0:
            fun(None)
        else:
            fun(*args)
    except Unavailable as e:
        msg = str(e)
        assert re.search('[Unavailable exception]', msg), "Expecting unavailable exception, got: " + msg
    except Exception as e:
        assert False, "Expecting unavailable exception, got: " + str(e)
    else:
        assert False, "Expecting unavailable exception but no exception was raised"

def assert_invalid(session, query, matching=None):
    try:
        res = session.execute(query)
        assert False, "Expecting query to be invalid: got %s" % res
    except AssertionError as e:
        raise e
    except InvalidRequest as e:
        msg = str(e)
        if matching is not None:
            assert re.search(matching, msg), "Error message does not contain " + matching + " (error = " + msg + ")"

def assert_syntax_invalid(session, query, matching=None):
    try:
        res = session.execute(query)
        assert False, "Expecting query to be invalid: got %s" % res
    except AssertionError as e:
        raise e
    except SyntaxException as e:
        msg = str(e)
        if matching is not None:
            assert re.search(matching, msg), "Error message does not contain " + matching + " (error = " + msg + ")"


def assert_one(cursor, query, expected, cl=ConsistencyLevel.ONE):
    simple_query = SimpleStatement(query, consistency_level=cl)
    res = cursor.execute(simple_query)
    list_res = rows_to_list(res)
    assert list_res == [expected], "Expected %s from %s, but got %s" % (expected, query, list_res)

def assert_none(cursor, query, cl=ConsistencyLevel.ONE):
    simple_query = SimpleStatement(query, consistency_level=cl)
    res = cursor.execute(simple_query)
    list_res = rows_to_list(res)
    assert list_res == [], "Expected %s from %s, but got %s" % (expected, query, list_res)

def assert_all(cursor, query, expected, cl=ConsistencyLevel.ONE):
    simple_query = SimpleStatement(query, consistency_level=cl)
    res = cursor.execute(simple_query)
    list_res = rows_to_list(res)
    assert list_res == expected, "Expected %s from %s, but got %s" % (expected, query, list_res)

def assert_almost_equal(*args, **kwargs):
    try:
        error = kwargs['error']
    except KeyError:
        error = 0.16

    vmax = max(args)
    vmin = min(args)
    assert vmin > vmax * (1.0 - error), "values not within %.2f%% of the max: %s" % (error * 100, args)
<commit_msg>Remove use of undeclared variable in assert_none<commit_after>import re
from cassandra import InvalidRequest, Unavailable, ConsistencyLevel
from cassandra.query import SimpleStatement
from cassandra.protocol import SyntaxException
from pytools import rows_to_list

def assert_unavailable(fun, *args):
    try:
        if len(args) == 0:
            fun(None)
        else:
            fun(*args)
    except Unavailable as e:
        msg = str(e)
        assert re.search('[Unavailable exception]', msg), "Expecting unavailable exception, got: " + msg
    except Exception as e:
        assert False, "Expecting unavailable exception, got: " + str(e)
    else:
        assert False, "Expecting unavailable exception but no exception was raised"

def assert_invalid(session, query, matching=None):
    try:
        res = session.execute(query)
        assert False, "Expecting query to be invalid: got %s" % res
    except AssertionError as e:
        raise e
    except InvalidRequest as e:
        msg = str(e)
        if matching is not None:
            assert re.search(matching, msg), "Error message does not contain " + matching + " (error = " + msg + ")"

def assert_syntax_invalid(session, query, matching=None):
    try:
        res = session.execute(query)
        assert False, "Expecting query to be invalid: got %s" % res
    except AssertionError as e:
        raise e
    except SyntaxException as e:
        msg = str(e)
        if matching is not None:
            assert re.search(matching, msg), "Error message does not contain " + matching + " (error = " + msg + ")"


def assert_one(cursor, query, expected, cl=ConsistencyLevel.ONE):
    simple_query = SimpleStatement(query, consistency_level=cl)
    res = cursor.execute(simple_query)
    list_res = rows_to_list(res)
    assert list_res == [expected], "Expected %s from %s, but got %s" % (expected, query, list_res)

def assert_none(cursor, query, cl=ConsistencyLevel.ONE):
    simple_query = SimpleStatement(query, consistency_level=cl)
    res = cursor.execute(simple_query)
    list_res = rows_to_list(res)
    assert list_res == [], "Expected nothing from %s, but got %s" % (query, list_res)

def assert_all(cursor, query, expected, cl=ConsistencyLevel.ONE):
    simple_query = SimpleStatement(query, consistency_level=cl)
    res = cursor.execute(simple_query)
    list_res = rows_to_list(res)
    assert list_res == expected, "Expected %s from %s, but got %s" % (expected, query, list_res)

def assert_almost_equal(*args, **kwargs):
    try:
        error = kwargs['error']
    except KeyError:
        error = 0.16

    vmax = max(args)
    vmin = min(args)
    assert vmin > vmax * (1.0 - error), "values not within %.2f%% of the max: %s" % (error * 100, args)

{'fraction_non_alphanumeric': 0.10377704437110377, 'fraction_numerical': 0.003667033370003667, 'mean_word_length': 3.235248447204969, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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}}
{'dir': 'git-commits-cleaned', 'id': '2078074', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1621, 'n_words': 525}