From b69b9eeedc42836991ea6051c6ccda3f0a18eddd Mon Sep 17 00:00:00 2001 From: Ruud Schroen Date: Wed, 27 Jun 2018 20:44:33 +0200 Subject: [PATCH 1/4] Tests using filesystem now make use of tmpdir --- nxstart/tests/test_utils_files.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nxstart/tests/test_utils_files.py b/nxstart/tests/test_utils_files.py index fb7677b..c4eca6b 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,21 +14,19 @@ 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 = 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 = 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) From a4398a96f01e7596a6fc7c7e38d1c9d7be1cb539 Mon Sep 17 00:00:00 2001 From: Ruud Schroen Date: Wed, 27 Jun 2018 20:45:19 +0200 Subject: [PATCH 2/4] Version 1.0.2 --- nxstart/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxstart/version.py b/nxstart/version.py index cd7ca49..a6221b3 100644 --- a/nxstart/version.py +++ b/nxstart/version.py @@ -1 +1 @@ -__version__ = '1.0.1' +__version__ = '1.0.2' From b15a42cfb5a323f49d514bb38d5bfcea98efce2d Mon Sep 17 00:00:00 2001 From: Ruud Schroen Date: Wed, 27 Jun 2018 20:54:39 +0200 Subject: [PATCH 3/4] Wrapped tmpdir with str --- nxstart/tests/test_utils_files.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nxstart/tests/test_utils_files.py b/nxstart/tests/test_utils_files.py index c4eca6b..9b872c7 100644 --- a/nxstart/tests/test_utils_files.py +++ b/nxstart/tests/test_utils_files.py @@ -17,13 +17,13 @@ def test_get_full_path(): def test_check_and_create_directory(tmpdir): new_folder_path = tmpdir.join(DIRECTORY_NAME) - check_and_create_directory(new_folder_path) + check_and_create_directory(str(new_folder_path)) assert os.path.isdir(new_folder_path) def test_replace_in_file(tmpdir): new_test_file_path = tmpdir.join('testfile.txt') - with open(new_test_file_path, 'w') as f: + with open(str(new_test_file_path), 'w') as f: f.write('TEXT_PLACEHOLDER') replace_in_file(new_test_file_path, { 'TEXT_PLACEHOLDER': 'NEW_TEXT', From fc410abe63646acad4be0e1a35271063daf2384c Mon Sep 17 00:00:00 2001 From: Ruud Schroen Date: Wed, 27 Jun 2018 20:59:07 +0200 Subject: [PATCH 4/4] Fixed tests so they work with Travis --- nxstart/tests/test_utils_files.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nxstart/tests/test_utils_files.py b/nxstart/tests/test_utils_files.py index 9b872c7..32ca0a8 100644 --- a/nxstart/tests/test_utils_files.py +++ b/nxstart/tests/test_utils_files.py @@ -15,15 +15,15 @@ def test_get_full_path(): def test_check_and_create_directory(tmpdir): - new_folder_path = tmpdir.join(DIRECTORY_NAME) + new_folder_path = str(tmpdir.join(DIRECTORY_NAME)) - check_and_create_directory(str(new_folder_path)) + check_and_create_directory(new_folder_path) assert os.path.isdir(new_folder_path) def test_replace_in_file(tmpdir): - new_test_file_path = tmpdir.join('testfile.txt') - with open(str(new_test_file_path), 'w') as f: + 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',