From 88c730157d4fd3bd279a884767cff72f4a573c5e Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Thu, 7 Feb 2019 22:43:56 +0100 Subject: [PATCH] improve tests cleanup --- tests-ng/transformations.sh | 2 +- tests.sh | 3 ++- tests/helpers.py | 3 ++- tests/test_install.py | 1 + tests/test_update.py | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests-ng/transformations.sh b/tests-ng/transformations.sh index 2fc4551..661d7c2 100755 --- a/tests-ng/transformations.sh +++ b/tests-ng/transformations.sh @@ -193,7 +193,7 @@ content=`cat ${tmpy}/a/somefile` [ ! -e ${tmps}/dotfiles/def ] && exit 1 ## CLEANING -rm -rf ${tmps} ${tmpd} +rm -rf ${tmps} ${tmpd} ${tmpx} ${tmpy} echo "OK" exit 0 diff --git a/tests.sh b/tests.sh index 61f3589..7a58f99 100755 --- a/tests.sh +++ b/tests.sh @@ -23,8 +23,9 @@ set -e # execute tests with coverage PYTHONPATH=dotdrop ${nosebin} -s --with-coverage --cover-package=dotdrop +#PYTHONPATH=dotdrop python3 -m pytest tests -# execute bash script tests +## execute bash script tests for scr in tests-ng/*.sh; do ${scr} done diff --git a/tests/helpers.py b/tests/helpers.py index a372f97..d43bd18 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -32,7 +32,8 @@ def clean(path): def get_string(length): """Get a random string of length 'length'""" alpha = string.ascii_uppercase + string.digits - return ''.join(random.choice(alpha) for _ in range(length)) + temp = ''.join(random.choice(alpha) for _ in range(length)) + return 'dotdrop-tests-{}'.format(temp) def get_tempdir(): diff --git a/tests/test_install.py b/tests/test_install.py index 68f2930..0d3b4a5 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -150,6 +150,7 @@ exec bspwm # to test actions value = get_string(12) fact = '/tmp/action' + self.addCleanup(clean, fact) act1 = Action('testaction', 'post', 'echo "{}" > {}'.format(value, fact)) f8, c8 = create_random_file(tmp) diff --git a/tests/test_update.py b/tests/test_update.py index eeea5af..d7d0070 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -57,6 +57,7 @@ class TestUpdate(unittest.TestCase): dpath = os.path.join(fold_config, get_string(5)) dir1 = create_dir(dpath) dirf1, _ = create_random_file(dpath) + self.addCleanup(clean, dir1) # create the config file profile = get_string(5)