<commit_before>import os
import pytest
import tarfile
import tempfile
import yaml

from grader.models.submission import SubmissionImportError


def init_and_build_roster(p_and_r):
    path = p_and_r(["init", "cpl"])
    config_path = os.path.join(path, "grader.yml")

    with open(config_path) as config:
        content = yaml.load(config)
        content['roster'] = [
            {'name': '<NAME>', 'id': 'fmm000'},
            {'name': '<NAME>', 'id': 'jtd111'},
        ]

    with open(config_path, 'w') as config:
        config.write(yaml.dump(content))

    return path


def make_student_folder(dest, student_id, filenames=["main.py"]):
    student_dir = os.path.join(dest, student_id)
    os.mkdir(student_dir)
    for filename in filenames:
        with open(os.path.join(student_dir, filename), 'w') as f:
            f.write("")
    return student_dir


def make_student_tarball(dest, student_id, filenames=["main.py"]):
    student_tarball = os.path.join(dest, student_id + ".tar.gz")

    with tempfile.TemporaryDirectory() as tempdir:
        student_dir = make_student_folder(tempdir, student_id, filenames)
        with tarfile.open(student_tarball, "w:gz") as tar:
            tar.add(student_dir, student_id)
<commit_msg>Assert that we're making the tempdir correctly<commit_after>import os
import pytest
import tarfile
import tempfile
import yaml

from grader.models.submission import SubmissionImportError


def init_and_build_roster(p_and_r):
    path = p_and_r(["init", "cpl"])
    config_path = os.path.join(path, "grader.yml")

    assert os.path.exists(path)

    with open(config_path) as config:
        content = yaml.load(config)
        content['roster'] = [
            {'name': '<NAME>', 'id': 'fmm000'},
            {'name': '<NAME>', 'id': 'jtd111'},
        ]

    with open(config_path, 'w') as config:
        config.write(yaml.dump(content))

    return path


def make_student_folder(dest, student_id, filenames=["main.py"]):
    student_dir = os.path.join(dest, student_id)
    os.mkdir(student_dir)
    for filename in filenames:
        with open(os.path.join(student_dir, filename), 'w') as f:
            f.write("")
    return student_dir


def make_student_tarball(dest, student_id, filenames=["main.py"]):
    student_tarball = os.path.join(dest, student_id + ".tar.gz")

    with tempfile.TemporaryDirectory() as tempdir:
        student_dir = make_student_folder(tempdir, student_id, filenames)
        with tarfile.open(student_tarball, "w:gz") as tar:
            tar.add(student_dir, student_id)

{'fraction_non_alphanumeric': 0.13126959247648903, 'fraction_numerical': 0.004702194357366771, 'mean_word_length': 3.416955017301038, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5608305', 'n_tokens_mistral': 878, 'n_tokens_neox': 851, 'n_words': 186}