<commit_before>import logging

import logutils
import pytest
from logutils.colorize import ColorizingStreamHandler

from py2neo import cypher, neo4j

# ToDo: possible environment constants
DEFAULT_DB = "http://localhost:7474/db/data/"
PY2NEO_LOGGING_LEVEL_COLOUR_MAP = {
    10: (None, 'blue', True),
    20: (None, 'blue', True),
    30: (None, 'yellow', True),
    40: ('red', 'white', True),
    50: ('red', 'white', True),
}

logger = logging.getLogger('pytest_configure')
logger.setLevel(logging.INFO)


def pytest_configure(config):
    db = neo4j.GraphDatabaseService(DEFAULT_DB)
    rels = next(db.match(), None)
    if rels:
        logging.warning(
            'Test Runner will only operate on an empty graph.    '
            'Either clear the DB with `neotool clear` or provide '
            'a differnt DB URI ')

        pytest.exit(1)

    handler = ColorizingStreamHandler()
    handler.level_map = PY2NEO_LOGGING_LEVEL_COLOUR_MAP
    logger.addHandler(handler)

    logger.info('- all logging captured at >= DEUBG and piped '
                'to stdout for test failures.                 ')
    logger.info('- tests running on Neo4J %s', db.neo4j_version)


@pytest.fixture
def graph_db(request):
    db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")
    db.clear()
    return db


@pytest.fixture
def session(request, graph_db):
    session = cypher.Session()
    return session<commit_msg>remove fixture that we don't appear to need<commit_after>import logging

import logutils
import pytest
from logutils.colorize import ColorizingStreamHandler

from py2neo import cypher, neo4j

# ToDo: possible environment constants
DEFAULT_DB = "http://localhost:7474/db/data/"
PY2NEO_LOGGING_LEVEL_COLOUR_MAP = {
    10: (None, 'blue', True),
    20: (None, 'blue', True),
    30: (None, 'yellow', True),
    40: ('red', 'white', True),
    50: ('red', 'white', True),
}

logger = logging.getLogger('pytest_configure')
logger.setLevel(logging.INFO)


def pytest_configure(config):
    db = neo4j.GraphDatabaseService(DEFAULT_DB)
    rels = next(db.match(), None)
    if rels:
        logging.warning(
            'Test Runner will only operate on an empty graph.    '
            'Either clear the DB with `neotool clear` or provide '
            'a differnt DB URI ')

        pytest.exit(1)

    handler = ColorizingStreamHandler()
    handler.level_map = PY2NEO_LOGGING_LEVEL_COLOUR_MAP
    logger.addHandler(handler)

    logger.info('- all logging captured at >= DEUBG and piped '
                'to stdout for test failures.                 ')
    logger.info('- tests running on Neo4J %s', db.neo4j_version)


@pytest.fixture
def graph_db(request):
    db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")
    db.clear()
    return db

# ToDo: varsion marker

{'fraction_non_alphanumeric': 0.11372549019607843, 'fraction_numerical': 0.019251336898395723, 'mean_word_length': 3.1693907875185734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3778793', 'n_tokens_mistral': 947, 'n_tokens_neox': 904, 'n_words': 239}