Skip to content

Commit

Permalink
Tests: Use pathlib for files read/write (test_cookiecutter_local_no_i…
Browse files Browse the repository at this point in the history
…nput.py)
  • Loading branch information
insspb committed Jun 8, 2022
1 parent eef9a82 commit 15e3bd0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_cookiecutter_local_no_input.py
Expand Up @@ -5,6 +5,7 @@
"""
import os
import textwrap
from pathlib import Path

import pytest

Expand Down Expand Up @@ -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

Expand All @@ -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 (
Expand Down

0 comments on commit 15e3bd0

Please sign in to comment.