Tests: Use pathlib for files read/write (test_cookiecutter_local_no_input.py)
@@ -5,6 +5,7 @@ verify result with different settings in `cookiecutter.json`.
"""
import os
import textwrap
+from pathlib import Path
import pytest
@@ -65,7 +66,7 @@ def test_cookiecutter_no_input_return_rendered_file():
"""Verify Jinja2 templating correctly works in `cookiecutter.json` file."""
project_dir = main.cookiecutter('tests/fake-repo-pre', no_input=True)
assert project_dir == os.path.abspath('fake-project')
- with open(os.path.join(project_dir, 'README.rst')) as fh:
+ with Path(project_dir, 'README.rst').open() as fh:
contents = fh.read()
assert "Project name: **Fake Project**" in contents
@@ -76,7 +77,7 @@ def test_cookiecutter_dict_values_in_context():
project_dir = main.cookiecutter('tests/fake-repo-dict', no_input=True)
assert project_dir == os.path.abspath('fake-project-dict')
- with open(os.path.join(project_dir, 'README.md')) as fh:
+ with Path(project_dir, 'README.md').open() as fh:
contents = fh.read()
assert (
