<commit_before>import os
import urllib
import zipfile
import subprocess

CACHE_FOLDER = '.cache'
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-master')
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
TEST_DIR = 'test'


class IntegrationTestFile(object):
    def __init__(self, path):
        self.path = path

    def run(self):
        output = subprocess.check_output([VSPEC_RUNNER, VSPEC_FOLDER, self.path])
        for line in output.splitlines():
            if line.startswith('not ok'):
                print(output)
                assert False

    def __repr__(self):
        return "<%s: %s>"  % (type(self), self.path)


def pytest_configure(config):
    print(subprocess.check_output(['vim', '--version']))
    if not os.path.isdir(CACHE_FOLDER):
        os.mkdir(CACHE_FOLDER)

    if not os.path.exists(VSPEC_FOLDER):
        url = 'https://github.com/kana/vim-vspec/archive/master.zip'
        name, hdrs = urllib.urlretrieve(url)
        z = zipfile.ZipFile(name)
        for n in z.namelist():
            dest = os.path.join(CACHE_FOLDER, n)
            destdir = os.path.dirname(dest)
            if not os.path.isdir(destdir):
              os.makedirs(destdir)
            data = z.read(n)
            if not os.path.isdir(dest):
                with open(dest, 'w') as f:
                    f.write(data)
        z.close()
        os.chmod(VSPEC_RUNNER, 0777)


def pytest_generate_tests(metafunc):
    """
    :type metafunc: _pytest.python.Metafunc
    """
    def collect_tests():
        for f in os.listdir(TEST_DIR):
            yield IntegrationTestFile(os.path.join(TEST_DIR, f))

    metafunc.parametrize('case', list(collect_tests()))<commit_msg>fix a few problems with conftest<commit_after>import os
import urllib
import zipfile
import subprocess

CACHE_FOLDER = '.cache'
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-master')
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
TEST_DIR = 'test'


class IntegrationTestFile(object):
    def __init__(self, path):
        self.path = path

    def run(self):
        output = subprocess.check_output([VSPEC_RUNNER, VSPEC_FOLDER, self.path])
        for line in output.splitlines():
            if line.startswith('not ok') or line.startswith('Error'):
                print(output)
                assert False

    def __repr__(self):
        return "<%s: %s>"  % (type(self), self.path)


def pytest_configure(config):
    print(subprocess.check_output(['vim', '--version']))
    if not os.path.isdir(CACHE_FOLDER):
        os.mkdir(CACHE_FOLDER)

    if not os.path.exists(VSPEC_FOLDER):
        url = 'https://github.com/kana/vim-vspec/archive/master.zip'
        name, hdrs = urllib.urlretrieve(url)
        z = zipfile.ZipFile(name)
        for n in z.namelist():
            dest = os.path.join(CACHE_FOLDER, n)
            destdir = os.path.dirname(dest)
            if not os.path.isdir(destdir):
              os.makedirs(destdir)
            data = z.read(n)
            if not os.path.isdir(dest):
                with open(dest, 'w') as f:
                    f.write(data)
        z.close()
        os.chmod(VSPEC_RUNNER, 0777)


def pytest_generate_tests(metafunc):
    """
    :type metafunc: _pytest.python.Metafunc
    """
    def collect_tests():
        for f in os.listdir(TEST_DIR):
            if f.endswith('.vim'):
                yield IntegrationTestFile(os.path.join(TEST_DIR, f))

    metafunc.parametrize('case', list(collect_tests()))
{'fraction_non_alphanumeric': 0.1277330264672037, 'fraction_numerical': 0.0023014959723820483, 'mean_word_length': 2.4188790560471976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6758594', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1176, 'n_words': 226}