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

from circuits import Component
from circuits.io import File, Write

class App(Component):

    def __init__(self, *args):
        super(App, self).__init__()

        self._file = File(*args)
        self._file.register(self)

        self.data = None
        self.eof = False

    def read(self, data):
        self.data = data

    def eof(self):
        self.eof = True

def test_write(tmpdir):
    sockpath = tmpdir.ensure("helloworld.txt")
    filename = str(sockpath)

    app = App(filename, "w")
    app.start()
    app.push(Write("Hello World!"))
    app.stop()

    f = open(filename, "r")
    s = f.read()
    assert s == "Hello World!"

def test_read(tmpdir):
    sockpath = tmpdir.ensure("helloworld.txt")
    filename = str(sockpath)

    f = open(filename, "w")
    f.write("Hello World!")
    f.close()

    app = App(filename, "r")
    app.start()

    while not app.eof:
        pass<commit_msg>tests.io.test_io: Added some sleep so this test works properly<commit_after>#!/usr/bin/env python

from time import sleep

from circuits import Component
from circuits.io import File, Write

class App(Component):

    def __init__(self, *args):
        super(App, self).__init__()

        self._file = File(*args)
        self._file.register(self)

        self.data = None
        self.eof = False

    def read(self, data):
        self.data = data

    def eof(self):
        self.eof = True

def test_write(tmpdir):
    sockpath = tmpdir.ensure("helloworld.txt")
    filename = str(sockpath)

    app = App(filename, "w")
    app.start()
    app.push(Write("Hello World!"))
    sleep(1)
    app.stop()

    f = open(filename, "r")
    s = f.read()
    assert s == "Hello World!"

def test_read(tmpdir):
    sockpath = tmpdir.ensure("helloworld.txt")
    filename = str(sockpath)

    f = open(filename, "w")
    f.write("Hello World!")
    f.close()

    app = App(filename, "r")
    app.start()

    while not app.eof:
        pass
{'fraction_non_alphanumeric': 0.13832997987927564, 'fraction_numerical': 0.0005030181086519115, 'mean_word_length': 2.520353982300885, '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': '1735452', 'n_tokens_mistral': 689, 'n_tokens_neox': 661, 'n_words': 164}