<commit_before>import immobilus  # noqa

import os
import random
import shutil

import pytest

import config
from skylines import database, create_app
from skylines.app import SkyLines

from tests import setup_db, teardown_db, clean_db
from tests.data import users, airspace


@pytest.fixture(scope="function")
def seeded_random():
    """
    Calls random.seed() with a constant to ensure that random always returns
    the same results.
    """

    random.seed(1234)


@pytest.fixture(scope="session")
def app():
    """Global skylines application fixture

    Initialized with testing config file.
    """
    yield create_app(config_file=config.TESTING_CONF_PATH)


@pytest.fixture(scope="function")
def files_folder(app):
    """
    Creates a clean upload folder
    """
    filesdir = app.config['SKYLINES_FILES_PATH']
    if os.path.exists(filesdir):
        shutil.rmtree(filesdir)

    os.makedirs(filesdir)


@pytest.fixture(scope="session")
def db(app):
    """Creates clean database schema and drops it on teardown

    Note, that this is a session scoped fixture, it will be executed only once
    and shared among all tests. Use `db_session` fixture to get clean database
    before each test.
    """
    assert isinstance(app, SkyLines)

    setup_db(app)
    yield database.db
    teardown_db()


@pytest.fixture(scope="function")
def db_session(db, app):
    """Provides clean database before each test. After each test,
    session.rollback() is issued.

    Also, database will be bootstrapped with some initial data.

    Return sqlalchemy session.
    """
    assert isinstance(app, SkyLines)

    with app.app_context():
        clean_db()
        yield db.session
        db.session.rollback()


@pytest.fixture(scope="function")
def test_admin(db_session):
    """
    Creates a test admin
    """
    user = users.test_admin()
    db_session.add(user)
    db_session.commit()
    return user


@pytest.fixture(scope="function")<commit_msg>tests: Adjust `db_session` documentation<commit_after>import immobilus  # noqa

import os
import random
import shutil

import pytest

import config
from skylines import database, create_app
from skylines.app import SkyLines

from tests import setup_db, teardown_db, clean_db
from tests.data import users, airspace


@pytest.fixture(scope="function")
def seeded_random():
    """
    Calls random.seed() with a constant to ensure that random always returns
    the same results.
    """

    random.seed(1234)


@pytest.fixture(scope="session")
def app():
    """Global skylines application fixture

    Initialized with testing config file.
    """
    yield create_app(config_file=config.TESTING_CONF_PATH)


@pytest.fixture(scope="function")
def files_folder(app):
    """
    Creates a clean upload folder
    """
    filesdir = app.config['SKYLINES_FILES_PATH']
    if os.path.exists(filesdir):
        shutil.rmtree(filesdir)

    os.makedirs(filesdir)


@pytest.fixture(scope="session")
def db(app):
    """Creates clean database schema and drops it on teardown

    Note, that this is a session scoped fixture, it will be executed only once
    and shared among all tests. Use `db_session` fixture to get clean database
    before each test.
    """
    assert isinstance(app, SkyLines)

    setup_db(app)
    yield database.db
    teardown_db()


@pytest.fixture(scope="function")
def db_session(db, app):
    """Provides clean database before each test. After each test,
    session.rollback() is issued.

    Return sqlalchemy session.
    """
    assert isinstance(app, SkyLines)

    with app.app_context():
        clean_db()
        yield db.session
        db.session.rollback()


@pytest.fixture(scope="function")
def test_admin(db_session):
    """
    Creates a test admin
    """
    user = users.test_admin()
    db_session.add(user)
    db_session.commit()
    return user


@pytest.fixture(scope="function")
{'fraction_non_alphanumeric': 0.09779260780287474, 'fraction_numerical': 0.002053388090349076, 'mean_word_length': 3.547257876312719, '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': '4762873', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1195, 'n_words': 349}