summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-04-24 14:58:53 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2020-04-24 14:58:53 +0200
commitda1f7de43f0470a3adae753d3a00299ce139565f (patch)
treea049e588eb400a8b37d6527c7192423a92b0a15d
parent159c39699bdb41f8f9000883c6cbc909828a422e (diff)
downloadpsutil-da1f7de43f0470a3adae753d3a00299ce139565f.tar.gz
docstring
-rw-r--r--psutil/tests/__init__.py8
-rwxr-xr-xpsutil/tests/test_system.py3
2 files changed, 7 insertions, 4 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index 84ca6bee..282194a1 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -791,7 +791,9 @@ def create_exe(outpath, c_code=None):
def unique_filename(prefix=TESTFN_PREFIX, suffix=""):
- return tempfile.mktemp(prefix=prefix, suffix=suffix)
+ name = tempfile.mktemp(prefix=prefix, suffix=suffix)
+ _testfiles_created.add(name)
+ return name
# ===================================================================
@@ -816,7 +818,9 @@ class TestCase(unittest.TestCase):
assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
def get_testfn(self, suffix=""):
- name = tempfile.mktemp(prefix=TESTFN_PREFIX, suffix=suffix)
+ """Return an absolute pathname of a file that did not exist at
+ the time the call is made."""
+ name = unique_filename(suffix=suffix)
self.addCleanup(safe_rmpath, name)
return name
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 815b5b3d..781b5529 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -15,7 +15,6 @@ import shutil
import signal
import socket
import sys
-import tempfile
import time
import psutil
@@ -586,7 +585,7 @@ class TestDiskAPIs(unittest.TestCase):
# if path does not exist OSError ENOENT is expected across
# all platforms
- fname = tempfile.mktemp()
+ fname = self.get_fname()
with self.assertRaises(FileNotFoundError):
psutil.disk_usage(fname)