<commit_before># coding: utf-8

import os
import unittest
import lode_runner
import subprocess

from StringIO import StringIO

from multiprocessing.pool import ThreadPool

from os import setsid, killpg
from signal import SIGTERM
from netifaces import ifaddresses, AF_INET
from ConfigParser import RawConfigParser


class TestCaseWithMicroApp(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        path = os.path.dirname(os.path.realpath(__file__))
        cls.p = subprocess.Popen(["gunicorn",
                                  "--log-level=warning",
                                  "-w 2",
                                  "-b 0.0.0.0:5000",
                                  "tests.functional.app.views:app"
                                  ], preexec_fn=setsid)
        config = RawConfigParser()
        config.read("%s/tests/config" % path)
        try:
            this_machine_ip = \
                ifaddresses('eth0').setdefault(AF_INET)[0]["addr"]
        except ValueError:
            this_machine_ip = \
                ifaddresses('wlan0').setdefault(AF_INET)[0]["addr"]
        config.set("Network", "addr", "http://%s:5000" % this_machine_ip)
        with open('%s/tests/config' % path, 'wb') as configfile:<commit_msg>Get free port for e2e test application<commit_after># coding: utf-8

import os
import unittest
import subprocess

from StringIO import StringIO

from multiprocessing.pool import ThreadPool

from os import setsid, killpg
from signal import SIGTERM
from netifaces import ifaddresses, AF_INET
from ConfigParser import RawConfigParser
from core.utils.network_utils import get_free_port


class TestCaseWithMicroApp(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.app_port = get_free_port()
        path = os.path.dirname(os.path.realpath(__file__))
        cls.p = subprocess.Popen(["gunicorn",
                                  "--log-level=warning",
                                  "-w 2",
                                  "-b 0.0.0.0:{}".format(cls.app_port),
                                  "tests.functional.app.views:app"
                                  ], preexec_fn=setsid)
        config = RawConfigParser()
        config.read("%s/tests/config" % path)
        try:
            this_machine_ip = \
                ifaddresses('eth0').setdefault(AF_INET)[0]["addr"]
        except ValueError:
            this_machine_ip = \
                ifaddresses('wlan0').setdefault(AF_INET)[0]["addr"]
        config.set("Network", "addr", "http://{}:{}".format(this_machine_ip, cls.app_port))
        with open('%s/tests/config' % path, 'wb') as configfile:
{'fraction_non_alphanumeric': 0.1101855357819008, 'fraction_numerical': 0.010980689132904203, 'mean_word_length': 2.0508083140877598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4537602', 'n_tokens_mistral': 794, 'n_tokens_neox': 760, 'n_words': 157}