<commit_before>#!/usr/bin/env python

import os
import sys
import shutil
from nose.tools import raises, with_setup
from dakotathon.run_component import run_component, main
from dakotathon.dakota import Dakota
from . import start_dir, data_dir


run_dir = os.getcwd()
local_config_file = 'config.yaml'
config_file = os.path.join(data_dir, local_config_file)
local_params_file = 'params.in'
params_file = os.path.join(data_dir, local_params_file)
results_file = 'results.out'


def setup_module():
    """Called before any tests are performed."""
    print('\n*** ' + __name__)


def setup():
    """Called at start of any test using it @with_setup()"""
    global d
    d = Dakota.from_file_like(config_file)


def teardown():
    """Called at end of any test using it @with_setup()"""
    if os.path.exists(results_file):
        os.remove(results_file)
    if os.path.exists(local_config_file):
        os.remove(local_config_file)
    if os.path.exists(local_params_file):
        os.remove(local_params_file)


def teardown_module():
    """Called after all tests have completed."""
    pass


@raises(IOError)
def test_run_component_unknown_config_file():
    """Tests run_component() fails with unknown config file."""
    run_component(params_file, results_file)


@raises(AttributeError)
@with_setup(setup, teardown)
def test_run_component_unknown_module():
    """Tests run_component() fails with unknown module."""
    d.component = 'foo'
    d.serialize(local_config_file)
    run_component(params_file, results_file)


@raises(TypeError)
@with_setup(setup, teardown)
def test_run_component_uninstalled_module():
    """Tests run_component() fails with module that's not installed."""
    d.serialize(local_config_file)
    os.environ['PATH'] = '.'
    run_component(params_file, results_file)


@raises(IndexError)
def test_main_no_args():
    """Tests main() fails without args."""
    sys.argv = []
    main()
<commit_msg>Fix errors in tests<commit_after>#!/usr/bin/env python

import os
import sys
import shutil
from nose.tools import raises, with_setup
from dakotathon.run_component import run_component, main
from dakotathon.dakota import Dakota
from . import start_dir, data_dir


run_dir = os.getcwd()
local_config_file = 'config.yaml'
config_file = os.path.join(data_dir, local_config_file)
local_params_file = 'params.in'
params_file = os.path.join(data_dir, local_params_file)
results_file = 'results.out'


def setup_module():
    """Called before any tests are performed."""
    print('\n*** ' + __name__)


def setup():
    """Called at start of any test using it @with_setup()"""
    global d
    d = Dakota.from_file_like(config_file)


def teardown():
    """Called at end of any test using it @with_setup()"""
    if os.path.exists(results_file):
        os.remove(results_file)
    if os.path.exists(local_config_file):
        os.remove(local_config_file)
    if os.path.exists(local_params_file):
        os.remove(local_params_file)


def teardown_module():
    """Called after all tests have completed."""
    pass


@raises(IOError)
def test_run_component_unknown_config_file():
    """Tests run_component() fails with unknown config file."""
    run_component(params_file, results_file)


@raises(ImportError)
@with_setup(setup, teardown)
def test_run_component_unknown_module():
    """Tests run_component() fails with unknown module."""
    d.component = 'foo'
    d.serialize(local_config_file)
    run_component(params_file, results_file)


@raises(IndexError)
def test_main_no_args():
    """Tests main() fails without args."""
    sys.argv = []
    main()

{'fraction_non_alphanumeric': 0.11648596052265776, 'fraction_numerical': 0.0, 'mean_word_length': 4.578294573643411, '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': '6598155', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1163, 'n_words': 284}