diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-04-24 17:17:34 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-04-24 17:17:34 +0200 |
commit | cbd1278e4b5c83014a8c7d2c2038997b0460245b (patch) | |
tree | 15dc47dd1402b3e79c0bb08b2a809fd625c3d0f7 | |
parent | c8980071ec89e67647cbd4bd9e330a9cd26d584b (diff) | |
download | psutil-cbd1278e4b5c83014a8c7d2c2038997b0460245b.tar.gz |
get rid of prefix arg
-rw-r--r-- | psutil/tests/__init__.py | 15 | ||||
-rwxr-xr-x | psutil/tests/test_unicode.py | 2 |
2 files changed, 8 insertions, 9 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 152659fc..b9eec342 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -775,7 +775,7 @@ def create_exe(outpath, c_code=None): os.chmod(outpath, st.st_mode | stat.S_IEXEC) -def get_testfn(prefix=None, suffix=""): +def get_testfn(suffix=""): """Return an absolute pathname of a file or dir that did not exist at the time this call is made. Also schedule it for safe deletion at interpreter exit. It's technically racy but probably @@ -783,8 +783,7 @@ def get_testfn(prefix=None, suffix=""): """ timer = getattr(time, 'perf_counter', time.time) while True: - if not prefix: - prefix = "%s%.9f-" % (TESTFN_PREFIX, timer()) + prefix = "%s%.9f-" % (TESTFN_PREFIX, timer()) name = tempfile.mktemp(prefix=prefix, suffix=suffix) if not os.path.isdir(name): _testfiles_created.add(name) @@ -994,7 +993,7 @@ def unix_socket_path(suffix=""): and tries to delete it on exit. """ assert psutil.POSIX - path = get_testfn(prefix=TESTFN_PREFIX, suffix=suffix) + path = get_testfn(suffix=suffix) try: yield path finally: @@ -1196,14 +1195,14 @@ def is_namedtuple(x): if POSIX: @contextlib.contextmanager - def copyload_shared_lib(dst_prefix=None): + def copyload_shared_lib(suffix=""): """Ctx manager which picks up a random shared CO lib used by this process, copies it in another location and loads it in memory via ctypes. Return the new absolutized path. """ exe = 'pypy' if PYPY else 'python' ext = ".so" - dst = get_testfn(prefix=dst_prefix, suffix=ext) + dst = get_testfn(suffix=suffix + ext) libs = [x.path for x in psutil.Process().memory_maps() if os.path.splitext(x.path)[1] == ext and exe in x.path.lower()] @@ -1216,7 +1215,7 @@ if POSIX: safe_rmpath(dst) else: @contextlib.contextmanager - def copyload_shared_lib(dst_prefix=None): + def copyload_shared_lib(suffix=""): """Ctx manager which picks up a random shared DLL lib used by this process, copies it in another location and loads it in memory via ctypes. @@ -1225,7 +1224,7 @@ else: from ctypes import wintypes from ctypes import WinError ext = ".dll" - dst = get_testfn(prefix=dst_prefix, suffix=ext) + dst = get_testfn(suffix=suffix + ext) libs = [x.path for x in psutil.Process().memory_maps() if x.path.lower().endswith(ext) and 'python' in os.path.basename(x.path).lower() and diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index d7bb8af6..43b16665 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -282,7 +282,7 @@ class _BaseFSAPIsTests(object): def test_memory_maps(self): # XXX: on Python 2, using ctypes.CDLL with a unicode path # opens a message box which blocks the test run. - with copyload_shared_lib(dst_prefix=self.funky_name) as funky_path: + with copyload_shared_lib(suffix=self.funky_suffix) as funky_path: def normpath(p): return os.path.realpath(os.path.normcase(p)) libpaths = [normpath(x.path) |