Skip to content

Commit dd2deb7

Browse files
authored
Remove usages of tempfile.mktemp (#3270)
* Remove usages of tempfile.mktemp * unused import --------- Co-authored-by: narrieta@microsoft <narrieta>
1 parent 3e2a70d commit dd2deb7

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

tests/common/utils/test_file_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_append_file(self):
8080
os.remove(test_file)
8181

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

109109
def test_findstr_in_file(self):
110-
fp = tempfile.mktemp()
110+
fp = os.path.join(self.tmp_dir, "test_findstr_in_file")
111111
with open(fp, 'w') as f:
112112
f.write(
113113
'''

tests/pa/test_provision.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import os
1919
import re
20-
import tempfile
2120
import unittest
2221

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

5655
def test_customdata(self):
5756
base64data = 'Q3VzdG9tRGF0YQ=='
58-
data = DefaultOSUtil().decode_customdata(base64data)
59-
fileutil.write_file(tempfile.mktemp(), data)
57+
DefaultOSUtil().decode_customdata(base64data)
6058

6159
@patch('azurelinuxagent.common.conf.get_provision_enabled',
6260
return_value=False)

0 commit comments

Comments
 (0)