<commit_before>"""pytest configuration for all tests."""
import asyncio
import pytest

import httpstan.main


@pytest.fixture(scope='session')
def host():
    """Host for server to listen on."""
    return '127.0.0.1'


@pytest.fixture(scope='session')
def port():
    """Port for server to listen on."""
    return 8080


@pytest.fixture(scope='module')
def loop_with_server(request, host, port):
    """Return event loop with httpstan server already running.

    HTTP server shutdown is handled as well.
    """
    l = asyncio.new_event_loop()
    asyncio.set_event_loop(None)

    # setup server
    app = httpstan.main.make_app(l)
    handler = app.make_handler(loop=l)
    srv = l.run_until_complete(l.create_server(handler, host, port))
    l.run_until_complete(app.startup())

    yield l  # yield control, test proper would start here

    # shutdown server
    srv.close()
    l.run_until_complete(srv.wait_closed())
    l.run_until_complete(app.shutdown())
    l.run_until_complete(handler.shutdown(60.0))
    l.run_until_complete(app.cleanup())

    # close loop
    l.close()
<commit_msg>Minor aiohttp 3 fixes in tests<commit_after>"""pytest configuration for all tests."""
import asyncio

import aiohttp
import pytest

import httpstan.main


@pytest.fixture(scope='session')
def host():
    """Host for server to listen on."""
    return '127.0.0.1'


@pytest.fixture(scope='session')
def port():
    """Port for server to listen on."""
    return 8080


@pytest.fixture(scope='module')
def loop_with_server(request, host, port):
    """Return event loop with httpstan server already running.

    HTTP server shutdown is handled as well.
    """
    l = asyncio.new_event_loop()
    asyncio.set_event_loop(None)

    # setup server
    app = httpstan.main.make_app(l)
    runner = aiohttp.web.AppRunner(app)
    l.run_until_complete(runner.setup())
    site = aiohttp.web.TCPSite(runner, 'localhost', 8080)
    l.run_until_complete(site.start())

    yield l  # yield control, test proper would start here

    l.run_until_complete(runner.cleanup())
    l.close()

{'fraction_non_alphanumeric': 0.12403846153846154, 'fraction_numerical': 0.013461538461538462, 'mean_word_length': 3.7511415525114153, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2801914', 'n_tokens_mistral': 707, 'n_tokens_neox': 683, 'n_words': 172}