Skip to content

Commit

Permalink
Merge pull request cookiecutter#553 from hackebrot/return-rendered-pr…
Browse files Browse the repository at this point in the history
…oject-dir

Return rendered project dir
  • Loading branch information
pydanny committed Oct 18, 2015
2 parents 736f7bb + eac14ca commit e229868
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cookiecutter/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,5 @@ def generate_files(repo_dir, context=None, output_dir='.',
# run post-gen hook from repo_dir
with work_in(repo_dir):
run_hook('post_gen_project', project_dir, context)

return project_dir
2 changes: 1 addition & 1 deletion cookiecutter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def cookiecutter(
dump(template_name, context)

# Create project from local context and project template.
generate_files(
return generate_files(
repo_dir=repo_dir,
context=context,
overwrite_if_exists=overwrite_if_exists,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cookiecutter_local_no_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,10 @@ def test_cookiecutter_templated_context():
no_input=True
)
assert os.path.isdir('fake-project-templated')


@pytest.mark.usefixtures('clean_system', 'remove_additional_dirs')
def test_cookiecutter_no_input_return_project_dir():
"""Call `cookiecutter()` with `no_input=True`."""
project_dir = main.cookiecutter('tests/fake-repo-pre', no_input=True)
assert project_dir == os.path.abspath('fake-project')
15 changes: 15 additions & 0 deletions tests/test_generate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ def test_generate_files_output_dir():
assert os.path.isfile('tests/custom_output_dir/inputpizzä/simple.txt')


@pytest.mark.usefixtures('clean_system', 'remove_additional_folders')
def test_return_rendered_project_dir():
os.mkdir('tests/custom_output_dir')
project_dir = generate.generate_files(
context={
'cookiecutter': {'food': 'pizzä'}
},
repo_dir=os.path.abspath('tests/test-generate-files'),
output_dir='tests/custom_output_dir'
)
assert project_dir == os.path.abspath(
'tests/custom_output_dir/inputpizzä/'
)


@pytest.mark.usefixtures('clean_system', 'remove_additional_folders')
def test_generate_files_permissions():
"""
Expand Down

0 comments on commit e229868

Please sign in to comment.