<commit_before>import logging
import pylibmc
import pytest

from anom import (
    Adapter, Key, Query, adapters, get_adapter, set_adapter,
    put_multi, delete_multi, set_default_namespace, set_namespace,
)
from anom.testing import Emulator
from concurrent import futures
from contextlib import contextmanager

from .models import Person, Mutant, Cat, Human, Eagle

logging.basicConfig(level=logging.DEBUG)


@contextmanager
def push_adapter(adapter):
    old_adapter = get_adapter()
    yield set_adapter(adapter)
    set_adapter(old_adapter)


@pytest.fixture(scope="session")
def emulator():
    emulator = Emulator()
    emulator.start(inject=True)
    yield
    emulator.stop()


@pytest.fixture(scope="session")
def memcache_client():
    client = pylibmc.Client(["127.0.0.1"], binary=True, behaviors={"cas": True})
    yield client
    client.flush_all()


@pytest.fixture(autouse=True)
def noop_adapter():
    with push_adapter(Adapter()) as adapter:
        yield adapter


@pytest.fixture(scope="session")
def datastore_adapter_instance(emulator):
    # This fixture exists to memoize the DS adapter instance to make
    # initial test setup much cheaper.
    return adapters.DatastoreAdapter()


@pytest.fixture
def datastore_adapter(datastore_adapter_instance):
    with push_adapter(datastore_adapter_instance) as adapter:
        yield adapter
        Query().delete()


@pytest.fixture()
def memcache_adapter(datastore_adapter, memcache_client):
    with push_adapter(adapters.MemcacheAdapter(memcache_client, datastore_adapter)) as adapter:
        yield adapter


@pytest.fixture(params=[None, "namespace"])
def default_namespace(request):
    namespace = getattr(request, "param", None)
    yield set_default_namespace(namespace)
    set_default_namespace(None)
    set_namespace(None)


@pytest.fixture(params=["datastore_adapter", "memcache_adapter"])
def adapter(request, default_namespace):
    return request.getfixturevalue(request.param)
<commit_msg>chore: add project="fake-project-name" to ds adapter<commit_after>import logging
import pylibmc
import pytest

from anom import (
    Adapter, Key, Query, adapters, get_adapter, set_adapter,
    put_multi, delete_multi, set_default_namespace, set_namespace,
)
from anom.testing import Emulator
from concurrent import futures
from contextlib import contextmanager

from .models import Person, Mutant, Cat, Human, Eagle

logging.basicConfig(level=logging.DEBUG)


@contextmanager
def push_adapter(adapter):
    old_adapter = get_adapter()
    yield set_adapter(adapter)
    set_adapter(old_adapter)


@pytest.fixture(scope="session")
def emulator():
    emulator = Emulator()
    emulator.start(inject=True)
    yield
    emulator.stop()


@pytest.fixture(scope="session")
def memcache_client():
    client = pylibmc.Client(["127.0.0.1"], binary=True, behaviors={"cas": True})
    yield client
    client.flush_all()


@pytest.fixture(autouse=True)
def noop_adapter():
    with push_adapter(Adapter()) as adapter:
        yield adapter


@pytest.fixture(scope="session")
def datastore_adapter_instance(emulator):
    # This fixture exists to memoize the DS adapter instance to make
    # initial test setup much cheaper.
    return adapters.DatastoreAdapter(project="fake-project-name")


@pytest.fixture
def datastore_adapter(datastore_adapter_instance):
    with push_adapter(datastore_adapter_instance) as adapter:
        yield adapter
        Query().delete()


@pytest.fixture()
def memcache_adapter(datastore_adapter, memcache_client):
    with push_adapter(adapters.MemcacheAdapter(memcache_client, datastore_adapter)) as adapter:
        yield adapter


@pytest.fixture(params=[None, "namespace"])
def default_namespace(request):
    namespace = getattr(request, "param", None)
    yield set_default_namespace(namespace)
    set_default_namespace(None)
    set_namespace(None)


@pytest.fixture(params=["datastore_adapter", "memcache_adapter"])
def adapter(request, default_namespace):
    return request.getfixturevalue(request.param)

{'fraction_non_alphanumeric': 0.09875621890547263, 'fraction_numerical': 0.0029850746268656717, 'mean_word_length': 5.2828125, 'pattern_counts': {'":': 2, '<': 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': '7012659', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1226, 'n_words': 279}