#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_output_folder
------------------

Test formerly known from a unittest residing in test_generate.py named
TestOutputFolder.test_output_folder
"""

from __future__ import unicode_literals
import logging
import os
import pytest

from cookiecutter import generate
from cookiecutter import utils


logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)


@pytest.fixture(scope='function')
def remove_output_folder(request):
    """
    Remove the output folder in case it exists on disk.
    """
    def finalizer_remove_output_folder():
        if os.path.exists('output_folder'):
            utils.rmtree('output_folder')
    request.addfinalizer(finalizer_remove_output_folder)


@pytest.mark.usefixtures('clean_system', 'remove_output_folder')
def test_output_folder():
    context = generate.generate_context(
        context_file='tests/test-output-folder/cookiecutter.json'
    )
    logging.debug('Context is {0}'.format(context))
    generate.generate_files(
        context=context,
        repo_dir='tests/test-output-folder'
    )

    something = """Hi!
My name is Audrey Greenfeld.
It is 2014."""
    something2 = open('output_folder/something.txt').read()
    assert something == something2

    in_folder = "The color is green and the letter is D."
    in_folder2 = open('output_folder/folder/in_folder.txt').read()
    assert in_folder == in_folder2

    assert os.path.isdir('output_folder/im_a.dir')
    assert os.path.isfile('output_folder/im_a.dir/im_a.file.py')

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_output_folder
------------------

Test formerly known from a unittest residing in test_generate.py named
TestOutputFolder.test_output_folder
"""

from __future__ import unicode_literals
import os
import pytest

from cookiecutter import generate
from cookiecutter import utils


@pytest.fixture(scope='function')
def remove_output_folder(request):
    """
    Remove the output folder in case it exists on disk.
    """
    def finalizer_remove_output_folder():
        if os.path.exists('output_folder'):
            utils.rmtree('output_folder')
    request.addfinalizer(finalizer_remove_output_folder)


@pytest.mark.usefixtures('clean_system', 'remove_output_folder')
def test_output_folder():
    context = generate.generate_context(
        context_file='tests/test-output-folder/cookiecutter.json'
    )
    generate.generate_files(
        context=context,
        repo_dir='tests/test-output-folder'
    )

    something = """Hi!
My name is Audrey Greenfeld.
It is 2014."""
    something2 = open('output_folder/something.txt').read()
    assert something == something2

    in_folder = "The color is green and the letter is D."
    in_folder2 = open('output_folder/folder/in_folder.txt').read()
    assert in_folder == in_folder2

    assert os.path.isdir('output_folder/im_a.dir')
    assert os.path.isfile('output_folder/im_a.dir/im_a.file.py')

Remove logging from test_output_folder