<commit_before>#!/usr/bin/env python

import pytest

from circuits import Manager
from circuits.core import pollers
from circuits.net.sockets import Pipe
from circuits.net.sockets import Close, Write

from .client import Client

def pytest_generate_tests(metafunc):
    metafunc.addcall(funcargs={"Poller": pollers.Select})
    #if pollers.HAS_POLL:
    #    metafunc.addcall(funcargs={"Poller": pollers.Poll})
    #if pollers.HAS_EPOLL:
    #    metafunc.addcall(funcargs={"Poller": pollers.EPoll})
    #if pollers.HAS_KQUEUE:
    #    metafunc.addcall(funcargs={"Poller": pollers.KQueue})

def test_pipe(Poller):
    m = Manager() + Poller()

    a, b = Pipe("a", "b")
    a.register(m)
    b.register(m)

    a = Client(channel=a.channel).register(m)
    b = Client(channel=b.channel).register(m)

    m.start()

    try:
        assert pytest.wait_for(a, "ready")
        assert pytest.wait_for(b, "ready")

        a.push(Write("foo"))
        assert pytest.wait_for(b, "data", b"foo")

        b.push(Write("foo"))
        assert pytest.wait_for(a, "data", b"foo")

        a.push(Close())
        assert pytest.wait_for(a, "disconnected")

        b.push(Close())
        assert pytest.wait_for(b, "disconnected")
    finally:
        m.stop()<commit_msg>send binary data to socket in test_pipe<commit_after>#!/usr/bin/env python

import pytest

from circuits import Manager
from circuits.core import pollers
from circuits.net.sockets import Pipe
from circuits.net.sockets import Close, Write

from .client import Client

def pytest_generate_tests(metafunc):
    metafunc.addcall(funcargs={"Poller": pollers.Select})
    #if pollers.HAS_POLL:
    #    metafunc.addcall(funcargs={"Poller": pollers.Poll})
    #if pollers.HAS_EPOLL:
    #    metafunc.addcall(funcargs={"Poller": pollers.EPoll})
    #if pollers.HAS_KQUEUE:
    #    metafunc.addcall(funcargs={"Poller": pollers.KQueue})

def test_pipe(Poller):
    m = Manager() + Poller()

    a, b = Pipe("a", "b")
    a.register(m)
    b.register(m)

    a = Client(channel=a.channel).register(m)
    b = Client(channel=b.channel).register(m)

    m.start()

    try:
        assert pytest.wait_for(a, "ready")
        assert pytest.wait_for(b, "ready")

        a.push(Write(b"foo"))
        assert pytest.wait_for(b, "data", b"foo")

        b.push(Write(b"foo"))
        assert pytest.wait_for(a, "data", b"foo")

        a.push(Close())
        assert pytest.wait_for(a, "disconnected")

        b.push(Close())
        assert pytest.wait_for(b, "disconnected")
    finally:
        m.stop()
{'fraction_non_alphanumeric': 0.14420062695924765, 'fraction_numerical': 0.0, 'mean_word_length': 3.164763458401305, 'pattern_counts': {'":': 8, '<': 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': '1742757', 'n_tokens_mistral': 935, 'n_tokens_neox': 916, 'n_words': 173}