Skip to content

Commit

Permalink
Merge pull request #3043 from copperchin/use-tmp-in-testutils
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Oct 26, 2022
2 parents 1f6f4a3 + 27f2c67 commit a51d75c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pelican/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
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))
Expand Down Expand Up @@ -468,7 +476,7 @@ def create_file(name, content):

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)
Expand All @@ -479,14 +487,14 @@ def test_clean_output_dir(self):

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('')
Expand Down

0 comments on commit a51d75c

Please sign in to comment.