diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-04-24 16:56:31 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-04-24 16:56:31 +0200 |
commit | 1454b284b793b1f4771dcf210ab86a304b8c5d8c (patch) | |
tree | a5cf934ff491e5c9cbb51d4cc1ecdece4b908b45 | |
parent | fc68cbd21bba321fbe07e96e464470def83ec147 (diff) | |
download | psutil-1454b284b793b1f4771dcf210ab86a304b8c5d8c.tar.gz |
get rid of TESTFN_UNICODE
-rw-r--r-- | psutil/tests/__init__.py | 4 | ||||
-rwxr-xr-x | psutil/tests/test_system.py | 4 | ||||
-rwxr-xr-x | psutil/tests/test_unicode.py | 11 |
3 files changed, 10 insertions, 9 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 3ee34962..da423283 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -74,7 +74,7 @@ __all__ = [ # constants 'APPVEYOR', 'DEVNULL', 'GLOBAL_TIMEOUT', 'MEMORY_TOLERANCE', 'NO_RETRIES', 'PYPY', 'PYTHON_EXE', 'ROOT_DIR', 'SCRIPTS_DIR', 'TESTFN_PREFIX', - 'TESTFN', 'TESTFN_UNICODE', 'TOX', 'TRAVIS', 'CIRRUS', 'CI_TESTING', + 'TESTFN', 'UNICODE_SUFFIX', 'TOX', 'TRAVIS', 'CIRRUS', 'CI_TESTING', 'VALID_PROC_STATUSES', "HAS_CPU_AFFINITY", "HAS_CPU_FREQ", "HAS_ENVIRON", "HAS_PROC_IO_COUNTERS", "HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT", @@ -145,7 +145,7 @@ if os.name == 'java': else: TESTFN_PREFIX = '@psutil-%s-' % os.getpid() TESTFN = os.path.join(os.path.realpath(os.getcwd()), TESTFN_PREFIX) -TESTFN_UNICODE = TESTFN + u("-ƒőő") +UNICODE_SUFFIX = u("-ƒőő") # An invalid unicode string. if PY3: TESTFN_INVALID_UNICODE = (TESTFN.encode('utf8') + b"f\xc0\x80").decode( diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index 88e28493..73401b3c 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -48,8 +48,8 @@ from psutil.tests import mock from psutil.tests import PYPY from psutil.tests import reap_children from psutil.tests import retry_on_failure -from psutil.tests import TESTFN_UNICODE from psutil.tests import TRAVIS +from psutil.tests import UNICODE_SUFFIX from psutil.tests import unittest @@ -594,7 +594,7 @@ class TestDiskAPIs(unittest.TestCase): def test_disk_usage_unicode(self): # See: https://github.com/giampaolo/psutil/issues/416 with self.assertRaises(UnicodeEncodeError): - psutil.disk_usage(TESTFN_UNICODE) + psutil.disk_usage(UNICODE_SUFFIX) def test_disk_usage_bytes(self): psutil.disk_usage(b'.') diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index b1af46c5..8d62aae6 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -104,8 +104,8 @@ from psutil.tests import safe_rmpath as _safe_rmpath from psutil.tests import skip_on_access_denied from psutil.tests import TESTFN_INVALID_UNICODE from psutil.tests import TESTFN_PREFIX -from psutil.tests import TESTFN_UNICODE from psutil.tests import TRAVIS +from psutil.tests import UNICODE_SUFFIX from psutil.tests import unittest from psutil.tests import unix_socket_path import psutil @@ -131,12 +131,13 @@ def safe_rmpath(path): return _safe_rmpath(path) -def subprocess_supports_unicode(name): +def subprocess_supports_unicode(suffix): """Return True if both the fs and the subprocess module can deal with a unicode file name. """ if PY3: return True + name = get_testfn(suffix=suffix) try: safe_rmpath(name) create_exe(name) @@ -297,11 +298,11 @@ class _BaseFSAPIsTests(object): @unittest.skipIf(PYPY and TRAVIS, "unreliable on PYPY + TRAVIS") @unittest.skipIf(MACOS and TRAVIS, "unreliable on TRAVIS") # TODO @unittest.skipIf(ASCII_FS, "ASCII fs") -@unittest.skipIf(not subprocess_supports_unicode(TESTFN_UNICODE), +@unittest.skipIf(not subprocess_supports_unicode(UNICODE_SUFFIX), "subprocess can't deal with unicode") class TestFSAPIs(_BaseFSAPIsTests, unittest.TestCase): """Test FS APIs with a funky, valid, UTF8 path name.""" - funky_suffix = os.path.basename(TESTFN_UNICODE) + funky_suffix = UNICODE_SUFFIX def expect_exact_path_match(self): # Do not expect psutil to correctly handle unicode paths on @@ -347,7 +348,7 @@ class TestNonFSAPIS(unittest.TestCase): # we use "è", which is part of the extended ASCII table # (unicode point <= 255). env = os.environ.copy() - funky_str = TESTFN_UNICODE if PY3 else 'è' + funky_str = UNICODE_SUFFIX if PY3 else 'è' env['FUNNY_ARG'] = funky_str sproc = get_test_subprocess(env=env) p = psutil.Process(sproc.pid) |