<commit_before>import pytest
import pymongo


mongo_client = pymongo.MongoClient("localhost:27017")
mongo_database = mongo_client["test-mongodb"]
mongo_collection = mongo_database["test-collection"]


@pytest.fixture()
def collection(request):
    # setup the db, clear if necessary
    # todo: the 'drop()' function from pymongo should work in future revisions
    mongo_collection.delete_many({})

    mongo_collection.insert_one({"Hello": "World"})

    def fin():
        mongo_client.close()

    request.addfinalizer(finalizer=fin)

    return mongo_collection


def test_initialize_collection(collection):
    c = collection.find({})
    assert c.count() == 1<commit_msg>testing fixture<commit_after>import pytest
import pymongo


mongo_client = pymongo.MongoClient("localhost:27017")
mongo_database = mongo_client["test-mongodb"]
mongo_collection = mongo_database["test-collection"]


@pytest.fixture()
def collection(request):
    # setup the db, clear if necessary
    # todo: the 'drop()' function from pymongo should work in future revisions
    mongo_collection.delete_many({})

    mongo_collection.insert_one({"Hello": "World"})

    def fin():
        mongo_client.close()

    request.addfinalizer(finalizer=fin)

    return mongo_collection


def test_initialize_collection(collection):
    c = collection.find({})
    assert c.count() == 1
    collection.insert_one({"Hello2": "World2"})


def test_initialize_collection2(collection):
    c = collection.find({})
    assert c.count() == 1


def test_initialize_collection3(collection):
    c = collection.find({})
    assert c.count() == 2
{'fraction_non_alphanumeric': 0.1181592039800995, 'fraction_numerical': 0.011194029850746268, 'mean_word_length': 4.6855123674911665, 'pattern_counts': {'":': 3, '<': 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': '7283593', 'n_tokens_mistral': 521, 'n_tokens_neox': 489, 'n_words': 108}