<commit_before># Module:   conftest
# Date:     6th December 2010
# Author:   <NAME>, prologic at shortcircuit dot net dot au

"""py.test config"""

from time import sleep

import collections


def wait_for(obj, attr, value=True, timeout=30.0):
    from circuits.core.manager import TIMEOUT
    for i in range(int(timeout / TIMEOUT)):
        if isinstance(value, collections.Callable):
            if value(obj, attr):
                return True
        elif getattr(obj, attr) == value:
            return True
        sleep(TIMEOUT)
    return False


def pytest_namespace():
    return dict((
        ("wait_for", wait_for),
    ))<commit_msg>- tests: Added ``conftests.wait_event`` to support tests that need to wait for   a specific event during testing.<commit_after># Module:   conftest
# Date:     6th December 2010
# Author:   <NAME>, prologic at shortcircuit dot net dot au

"""py.test config"""

from time import sleep

import collections


def wait_event(m, channel, target=None, timeout=30.0):
    from circuits.core.manager import TIMEOUT

    flag = False

    def handler(evt, handler, retval):
        nonlocal flag
        flag = True

    if target is None:
        target = m

    m.addHandler(handler, channel, target=target)

    for i in range(int(timeout / TIMEOUT)):
        if flag:
            return True
        sleep(TIMEOUT)


def wait_for(obj, attr, value=True, timeout=30.0):
    from circuits.core.manager import TIMEOUT
    for i in range(int(timeout / TIMEOUT)):
        if isinstance(value, collections.Callable):
            if value(obj, attr):
                return True
        elif getattr(obj, attr) == value:
            return True
        sleep(TIMEOUT)


def pytest_namespace():
    return dict((
        ("wait_event", wait_event),
        ("wait_for", wait_for),
    ))
{'fraction_non_alphanumeric': 0.09939593629873696, 'fraction_numerical': 0.01043382756727073, 'mean_word_length': 2.55859375, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6493560', 'n_tokens_mistral': 547, 'n_tokens_neox': 521, 'n_words': 176}