<commit_before>from os import path
from re import match

import pickle
import pytest

test_directory = path.dirname(path.realpath(__file__))


@pytest.fixture
def params(request):
    function_name = request.function.__name__
    challenge = match('test_(\w+)', function_name).group(1)

    picklefile = test_directory + '/input/' + challenge + '_input.pickle'

    return pickle.load(open(picklefile))


@pytest.fixture
def expected(request):
    function_name = request.function.__name__
    challenge = match('test_(\w+)', function_name).group(1)

    picklefile = test_directory + '/output/' + challenge + '_output.pickle'

    return pickle.load(open(picklefile))
<commit_msg>Properly close files in test fixtures.<commit_after>from os import path
from re import match

import pickle
import pytest

test_dir = path.dirname(path.realpath(__file__))


@pytest.fixture
def params(request):
    function_name = request.function.__name__
    challenge = match('test_(\w+)', function_name).group(1)

    picklefile = open(test_dir + '/input/' + challenge + '_input.pickle')
    result = pickle.load(picklefile)

    picklefile.close()

    return result


@pytest.fixture
def expected(request):
    function_name = request.function.__name__
    challenge = match('test_(\w+)', function_name).group(1)

    picklefile = open(test_dir + '/output/' + challenge + '_output.pickle')
    result = pickle.load(picklefile)

    picklefile.close()

    return result

{'fraction_non_alphanumeric': 0.12148249828414551, 'fraction_numerical': 0.002745367192862045, 'mean_word_length': 4.34065934065934, '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': '5802173', 'n_tokens_mistral': 467, 'n_tokens_neox': 457, 'n_words': 99}