<commit_before>import pytest

from gaphas.solver import Constraint, MultiConstraint, Variable


@pytest.fixture
def handler():
    events = []

    def handler(e):
        events.append(e)

    handler.events = events  # type: ignore[attr-defined]
    return handler


def test_constraint_propagates_variable_changed(handler):
    v = Variable()
    c = Constraint(v)
    c.add_handler(handler)

    v.value = 3

    assert handler.events == [c]


def test_multi_constraint(handler):
    v = Variable()
    c = Constraint(v)
    m = MultiConstraint(c)
    m.add_handler(handler)

    v.value = 3

    assert handler.events == [c]<commit_msg>Test default case for constraint.solve()<commit_after>import pytest

from gaphas.solver import Constraint, MultiConstraint, Variable


@pytest.fixture
def handler():
    events = []

    def handler(e):
        events.append(e)

    handler.events = events  # type: ignore[attr-defined]
    return handler


def test_constraint_propagates_variable_changed(handler):
    v = Variable()
    c = Constraint(v)
    c.add_handler(handler)

    v.value = 3

    assert handler.events == [c]


def test_multi_constraint(handler):
    v = Variable()
    c = Constraint(v)
    m = MultiConstraint(c)
    m.add_handler(handler)

    v.value = 3

    assert handler.events == [c]


def test_default_constraint_can_not_solve():
    v = Variable()
    c = Constraint(v)

    with pytest.raises(NotImplementedError):
        c.solve()
{'fraction_non_alphanumeric': 0.10609171800136892, 'fraction_numerical': 0.0027378507871321013, 'mean_word_length': 3.2254335260115607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3605711', 'n_tokens_mistral': 495, 'n_tokens_neox': 464, 'n_words': 106}