<commit_before>import json

from sforparser.apd import scraper

INPUT_FILE = 'data/apd/input.txt'


def test_output_strips_email_spaces():
    json_str = scraper(open(INPUT_FILE))

    data = json.loads(json_str)
    offensive_field = data[70]["locations"][0]["emails"]
    expected = [
        "<EMAIL>",
        "<EMAIL>",
        "<EMAIL>",
    ]

    assert offensive_field == expected<commit_msg>Switch to pytest fixture and generate artifact for circle ci<commit_after>import json
import os

import pytest

from sforparser.apd import scraper

INPUT_FILE = 'data/apd/input.txt'


@pytest.fixture
def data():
    json_str = scraper(open(INPUT_FILE))

    artifact_dir = os.getenv('CIRCLE_ARTIFACTS')
    if artifact_dir:
        artifact_file = os.path.join(artifact_dir, 'apd.json')
        open(artifact_file, 'w').write(json_str)

    return json.loads(json_str)


def test_output_strips_email_spaces(data):
    offensive_field = data[70]["locations"][0]["emails"]
    expected = [
        "<EMAIL>",
        "<EMAIL>",
        "<EMAIL>",
    ]

    assert offensive_field == expected
{'fraction_non_alphanumeric': 0.12648945921173235, 'fraction_numerical': 0.005499541704857928, 'mean_word_length': 3.569037656903766, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6391956', 'n_tokens_mistral': 385, 'n_tokens_neox': 376, 'n_words': 70}