Skip to content

Commit

Permalink
Remove usages of tempfile.mktemp (Azure#3270)
Browse files Browse the repository at this point in the history
* Remove usages of tempfile.mktemp

* unused import

---------

Co-authored-by: narrieta@microsoft <narrieta>
  • Loading branch information
narrieta authored Dec 3, 2024
1 parent 3e2a70d commit dd2deb7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/common/utils/test_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_append_file(self):
os.remove(test_file)

def test_findre_in_file(self):
fp = tempfile.mktemp()
fp = os.path.join(self.tmp_dir, "test_findre_in_file")
with open(fp, 'w') as f:
f.write(
'''
Expand All @@ -107,7 +107,7 @@ def test_findre_in_file(self):
fileutil.findre_in_file(fp, "^Do not match.*"))

def test_findstr_in_file(self):
fp = tempfile.mktemp()
fp = os.path.join(self.tmp_dir, "test_findstr_in_file")
with open(fp, 'w') as f:
f.write(
'''
Expand Down
4 changes: 1 addition & 3 deletions tests/pa/test_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import os
import re
import tempfile
import unittest

import azurelinuxagent.common.conf as conf
Expand Down Expand Up @@ -55,8 +54,7 @@ def test_provision(self, mock_util, distro_name, distro_version, distro_full_nam

def test_customdata(self):
base64data = 'Q3VzdG9tRGF0YQ=='
data = DefaultOSUtil().decode_customdata(base64data)
fileutil.write_file(tempfile.mktemp(), data)
DefaultOSUtil().decode_customdata(base64data)

@patch('azurelinuxagent.common.conf.get_provision_enabled',
return_value=False)
Expand Down

0 comments on commit dd2deb7

Please sign in to comment.