<commit_before>"""
Tests for dhcp2nest.util
"""
from nose.tools import with_setup, eq_
from tempfile import TemporaryDirectory
import os.path


from dhcp2nest.util import follow_file


TEMPDIR = None


def follow_setup():
    """
    Setup for follow_file tests
    """
    global TEMPDIR
    TEMPDIR = TemporaryDirectory()


def follow_teardown():
    """
    Teardown for follow_file tests
    """
    TEMPDIR.cleanup()


# #################
# follow_file tests
# #################
@with_setup(follow_setup, follow_teardown)
def test_basic_follow():
    tmp_fn = os.path.join(TEMPDIR.name, 'basic.log')
    with open(tmp_fn, 'w') as out_file:
        q = follow_file(tmp_fn)
        out_file.write('test line\n')
    eq_(q.get(timeout=5), 'test line\n')<commit_msg>Let the file follower initialize before testing<commit_after>"""
Tests for dhcp2nest.util
"""
from nose.tools import with_setup, eq_
from tempfile import TemporaryDirectory
import os.path
from time import sleep


from dhcp2nest.util import follow_file


TEMPDIR = None


def follow_setup():
    """
    Setup for follow_file tests
    """
    global TEMPDIR
    TEMPDIR = TemporaryDirectory()


def follow_teardown():
    """
    Teardown for follow_file tests
    """
    TEMPDIR.cleanup()


# #################
# follow_file tests
# #################
@with_setup(follow_setup, follow_teardown)
def test_basic_follow():
    tmp_fn = os.path.join(TEMPDIR.name, 'basic.log')
    with open(tmp_fn, 'w') as out_file:
        q = follow_file(tmp_fn)
        sleep(0.125)
        out_file.write('test line\n')
    eq_(q.get(timeout=5), 'test line\n')
{'fraction_non_alphanumeric': 0.14826302729528537, 'fraction_numerical': 0.00620347394540943, 'mean_word_length': 3.75811209439528, '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': '2313312', 'n_tokens_mistral': 560, 'n_tokens_neox': 537, 'n_words': 128}