Skip to content

Commit

Permalink
Merge branch 'master' into libt-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roedesh authored Jun 29, 2018
2 parents 33cc32d + 6cc38df commit bf43b84
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions nxstart/tests/test_utils_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""Includes tests for the functions in nxstart.utils.files"""

import os
import shutil

from nxstart.tests.helpers import DIRECTORY_NAME, assert_file_contains_strings
from nxstart.utils.files import check_and_create_directory, PROJECT_ROOT, get_full_path, replace_in_file
Expand All @@ -15,20 +14,18 @@ def test_get_full_path():
assert path == path_two


def test_check_and_create_directory():
new_folder_path = os.path.join(PROJECT_ROOT, 'tests', DIRECTORY_NAME)
def test_check_and_create_directory(tmpdir):
new_folder_path = str(tmpdir.join(DIRECTORY_NAME))

check_and_create_directory(new_folder_path)
assert os.path.isdir(new_folder_path)
shutil.rmtree(new_folder_path)


def test_replace_in_file():
new_test_file_path = os.path.join(PROJECT_ROOT, 'tests', 'testfile.txt')
def test_replace_in_file(tmpdir):
new_test_file_path = str(tmpdir.join('testfile.txt'))
with open(new_test_file_path, 'w') as f:
f.write('TEXT_PLACEHOLDER')
replace_in_file(new_test_file_path, {
'TEXT_PLACEHOLDER': 'NEW_TEXT',
})
assert_file_contains_strings(new_test_file_path, ['NEW_TEXT'])
os.remove(new_test_file_path)

0 comments on commit bf43b84

Please sign in to comment.