diff --git a/nxstart/tests/test_utils_files.py b/nxstart/tests/test_utils_files.py index c1aa2b7..f73b3ba 100644 --- a/nxstart/tests/test_utils_files.py +++ b/nxstart/tests/test_utils_files.py @@ -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 @@ -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)