<commit_before>from nose.tools import with_setup
from snake.core import Snake


snake = Snake()


@snake.task
def configure():
    pass


@snake.task
def build():
    pass


@snake.task
@snake.depends_on('configure', 'build')
def install():
    """Configure, build and install project"""


def setup_func():
    pass


def teardown_func():
    snake.called = set()


reset_snake = with_setup(setup_func, teardown_func)


def test_snake_defaults():
    snake = Snake()
    assert snake.called == set()
    assert snake.current_namespace == ''
    assert snake.tasks == {}
    assert snake.verbosity == 1


def test_registered_tasks():
    assert set(snake.tasks.keys()) == set(['configure', 'build', 'install'])

    for func in (configure, build, install):
        assert snake.tasks[func.__name__]['func'] is func

    assert snake.tasks['configure']['doc'] is None
    assert snake.tasks['install']['doc'] == "Configure, build and install project"


def test_stored_dependencies():
    assert install.depends_on == ('configure', 'build')


def test_task_overriding():
    snake = Snake()

    @snake.task
    @snake.depends_on('this')
    def task():
        """One description"""

    old_task = task

    @snake.task
    @snake.depends_on('that')
    def task():
        """Other description"""

    assert task is not old_task
    assert snake.tasks['task']['func'] is task
    assert snake.tasks['task']['doc'] == "Other description"


@reset_snake
def test_run_task():
    snake.run_task('build')
    assert snake.called == set(['build'])


@reset_snake
def test_run_task_with_dependencies():
    snake.run_task('install')
    assert snake.called == set(['configure', 'build', 'install'])


def test_run_snake():
    snake.run(['configure', 'build', 'install'])
    assert snake.called == set(['configure', 'build', 'install'])<commit_msg>Improve tests<commit_after>from nose.tools import with_setup
from snake.core import Snake


snake = Snake()
stack = []


@snake.task
def configure():
    stack.append('configure')


@snake.task
def build():
    stack.append('build')


@snake.task
@snake.depends_on('configure', 'build')
def install():
    """Configure, build and install project"""
    stack.append('install')


def teardown_func():
    stack[:] = []
    snake.called = set()


reset_snake = with_setup(teardown=teardown_func)


def test_snake_defaults():
    snake = Snake()
    assert snake.called == set()
    assert snake.current_namespace == ''
    assert snake.tasks == {}
    assert snake.verbosity == 1


def test_registered_tasks():
    assert set(snake.tasks.keys()) == set(['configure', 'build', 'install'])

    for func in (configure, build, install):
        assert snake.tasks[func.__name__]['func'] is func

    assert snake.tasks['configure']['doc'] is None
    assert snake.tasks['install']['doc'] == "Configure, build and install project"


def test_stored_dependencies():
    assert install.depends_on == ('configure', 'build')


def test_task_overriding():
    snake = Snake()

    @snake.task
    @snake.depends_on('this')
    def task():
        """One description"""

    old_task = task

    @snake.task
    @snake.depends_on('that')
    def task():
        """Other description"""

    assert task is not old_task
    assert snake.tasks['task']['func'] is task
    assert snake.tasks['task']['doc'] == "Other description"


@reset_snake
def test_run_task():
    snake.run_task('build')
    assert snake.called == set(['build'])
    assert stack == ['build']


@reset_snake
def test_run_task_with_dependencies():
    snake.run_task('install')
    assert snake.called == set(['configure', 'build', 'install'])


@reset_snake
def test_run_snake():
    snake.run(['install'])
    assert snake.called == set(['configure', 'build', 'install'])


@reset_snake
def test_task_called_once():
    snake.run(['configure', 'configure'])
    assert stack == ['configure']
{'fraction_non_alphanumeric': 0.1570841889117043, 'fraction_numerical': 0.000513347022587269, 'mean_word_length': 3.9266750948166877, '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': '6772839', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1210, 'n_words': 295}