summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Mayer <entroP@gmail.com>2022-10-25 14:11:33 -1000
committerGitHub <noreply@github.com>2022-10-25 14:11:33 -1000
commita51d75c8ed03cb757e1bbc03b3a470d539f35d27 (patch)
tree3e56858a01440a0e05c004d2a34c4fd1b9ecd6c8
parent1f6f4a3626831d7c39d103dfb022edfa8b0d5ec5 (diff)
parent27f2c678cbf2e07371a7161fcd8cf0cade22bddc (diff)
downloadpelican-a51d75c8ed03cb757e1bbc03b3a470d539f35d27.tar.gz
Merge pull request #3043 from copperchin/use-tmp-in-testutils
-rw-r--r--pelican/tests/test_utils.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py
index ee5146df..449a6814 100644
--- a/pelican/tests/test_utils.py
+++ b/pelican/tests/test_utils.py
@@ -20,6 +20,14 @@ from pelican.writers import Writer
class TestUtils(LoggedTestCase):
_new_attribute = 'new_value'
+ def setUp(self):
+ super().setUp()
+ self.temp_output = mkdtemp(prefix='pelicantests.')
+
+ def tearDown(self):
+ super().tearDown()
+ shutil.rmtree(self.temp_output)
+
@utils.deprecated_attribute(
old='_old_attribute', new='_new_attribute',
since=(3, 1, 0), remove=(4, 1, 3))
@@ -468,7 +476,7 @@ class TestUtils(LoggedTestCase):
def test_clean_output_dir(self):
retention = ()
- test_directory = os.path.join(os.path.dirname(__file__),
+ test_directory = os.path.join(self.temp_output,
'clean_output')
content = os.path.join(os.path.dirname(__file__), 'content')
shutil.copytree(content, test_directory)
@@ -479,14 +487,14 @@ class TestUtils(LoggedTestCase):
def test_clean_output_dir_not_there(self):
retention = ()
- test_directory = os.path.join(os.path.dirname(__file__),
+ test_directory = os.path.join(self.temp_output,
'does_not_exist')
utils.clean_output_dir(test_directory, retention)
self.assertFalse(os.path.exists(test_directory))
def test_clean_output_dir_is_file(self):
retention = ()
- test_directory = os.path.join(os.path.dirname(__file__),
+ test_directory = os.path.join(self.temp_output,
'this_is_a_file')
f = open(test_directory, 'w')
f.write('')