<commit_before>from collections import namedtuple
from dns import resolver, query
from unittest import TestCase

from vaurien.util import start_proxy, stop_proxy
from vaurienclient import Client as VClient
import dns.message
import dns.name
import os.path
import shlex
import subprocess
import tempfile
import time
import boto.ec2
import atexit

UnboundConf = namedtuple('UnboundConf', ('port', 'module'))

GoodRecord = "mwhooker.dev.banksimple.com. 300 IN A 172.16.31.10"


def make_config(conf):
    tpl = """
server:
        interface: 127.0.0.1
        port: {conf.port}
        username: ""
        do-daemonize: no
        verbosity: 2
        directory: ""
        logfile: ""
        chroot: ""
        pidfile: ""
        module-config: "python validator iterator"


remote-control:
        control-enable: no

python:
        python-script: "{conf.module}"
"""
    return tpl.format(conf=conf)

class TestBadNetword(TestCase):

    @staticmethod
    def _start_unbound(conf):
        nt = tempfile.NamedTemporaryFile(suffix='.conf')
        nt.write(make_config(conf))
        nt.flush()

        args = shlex.split("/usr/local/sbin/unbound -dv -c %s" % nt.name)
        time.sleep(1)
        testenv = os.environ.copy()
        testenv.update({
            'AWS_REGION': 'proxy',
            'http_proxy': 'localhost:8000',
            'UNBOUND_DEBUG': "1"
        })
        proc = subprocess.Popen(args, env=testenv)
        time.sleep(1)

        @atexit.register
        def last():
            try:
                proc.kill()
            except OSError as e:
                if e.errno != 3:
                    raise

        def finish():
            proc.terminate()
            proc.wait()
            nt.close()<commit_msg>it's a work and not a word.<commit_after>from collections import namedtuple
from dns import resolver, query
from unittest import TestCase

from vaurien.util import start_proxy, stop_proxy
from vaurienclient import Client as VClient
import dns.message
import dns.name
import os.path
import shlex
import subprocess
import tempfile
import time
import boto.ec2
import atexit

UnboundConf = namedtuple('UnboundConf', ('port', 'module'))

GoodRecord = "mwhooker.dev.banksimple.com. 300 IN A 172.16.31.10"


def make_config(conf):
    tpl = """
server:
        interface: 127.0.0.1
        port: {conf.port}
        username: ""
        do-daemonize: no
        verbosity: 2
        directory: ""
        logfile: ""
        chroot: ""
        pidfile: ""
        module-config: "python validator iterator"


remote-control:
        control-enable: no

python:
        python-script: "{conf.module}"
"""
    return tpl.format(conf=conf)

class TestBadNetwork(TestCase):

    @staticmethod
    def _start_unbound(conf):
        nt = tempfile.NamedTemporaryFile(suffix='.conf')
        nt.write(make_config(conf))
        nt.flush()

        args = shlex.split("/usr/local/sbin/unbound -dv -c %s" % nt.name)
        time.sleep(1)
        testenv = os.environ.copy()
        testenv.update({
            'AWS_REGION': 'proxy',
            'http_proxy': 'localhost:8000',
            'UNBOUND_DEBUG': "1"
        })
        proc = subprocess.Popen(args, env=testenv)
        time.sleep(1)

        @atexit.register
        def last():
            try:
                proc.kill()
            except OSError as e:
                if e.errno != 3:
                    raise

        def finish():
            proc.terminate()
            proc.wait()
            nt.close()
{'fraction_non_alphanumeric': 0.1113013698630137, 'fraction_numerical': 0.01598173515981735, 'mean_word_length': 2.0638111888111887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1033716', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1068, 'n_words': 261}