summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-04-24 17:01:06 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2020-04-24 17:01:06 +0200
commitb9f301a340379bd17ea32dcb75be3437efb077c4 (patch)
tree0d5e45f4d6a76a71cb5d192047e3ba77b9382785
parent1454b284b793b1f4771dcf210ab86a304b8c5d8c (diff)
downloadpsutil-b9f301a340379bd17ea32dcb75be3437efb077c4.tar.gz
get rid of TESTFN_INVALID_UNICODE
-rw-r--r--psutil/tests/__init__.py9
-rwxr-xr-xpsutil/tests/test_unicode.py8
2 files changed, 8 insertions, 9 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index da423283..e9f8f066 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -74,8 +74,8 @@ __all__ = [
# constants
'APPVEYOR', 'DEVNULL', 'GLOBAL_TIMEOUT', 'MEMORY_TOLERANCE', 'NO_RETRIES',
'PYPY', 'PYTHON_EXE', 'ROOT_DIR', 'SCRIPTS_DIR', 'TESTFN_PREFIX',
- 'TESTFN', 'UNICODE_SUFFIX', 'TOX', 'TRAVIS', 'CIRRUS', 'CI_TESTING',
- 'VALID_PROC_STATUSES',
+ 'TESTFN', 'UNICODE_SUFFIX', 'INVALID_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",
"HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS",
@@ -148,10 +148,9 @@ TESTFN = os.path.join(os.path.realpath(os.getcwd()), TESTFN_PREFIX)
UNICODE_SUFFIX = u("-ƒőő")
# An invalid unicode string.
if PY3:
- TESTFN_INVALID_UNICODE = (TESTFN.encode('utf8') + b"f\xc0\x80").decode(
- 'utf8', 'surrogateescape')
+ INVALID_UNICODE_SUFFIX = b"f\xc0\x80".decode('utf8', 'surrogateescape')
else:
- TESTFN_INVALID_UNICODE = TESTFN + "f\xc0\x80"
+ INVALID_UNICODE_SUFFIX = "f\xc0\x80"
ASCII_FS = sys.getfilesystemencoding().lower() in ('ascii', 'us-ascii')
diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py
index 8d62aae6..d7bb8af6 100755
--- a/psutil/tests/test_unicode.py
+++ b/psutil/tests/test_unicode.py
@@ -86,10 +86,10 @@ from psutil import WINDOWS
from psutil._compat import PY3
from psutil._compat import u
from psutil.tests import APPVEYOR
-from psutil.tests import CIRRUS
from psutil.tests import ASCII_FS
from psutil.tests import bind_unix_socket
from psutil.tests import chdir
+from psutil.tests import CIRRUS
from psutil.tests import copyload_shared_lib
from psutil.tests import create_exe
from psutil.tests import get_test_subprocess
@@ -97,12 +97,12 @@ from psutil.tests import get_testfn
from psutil.tests import HAS_CONNECTIONS_UNIX
from psutil.tests import HAS_ENVIRON
from psutil.tests import HAS_MEMORY_MAPS
+from psutil.tests import INVALID_UNICODE_SUFFIX
from psutil.tests import PYPY
from psutil.tests import reap_children
from psutil.tests import safe_mkdir
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 TRAVIS
from psutil.tests import UNICODE_SUFFIX
@@ -316,11 +316,11 @@ class TestFSAPIs(_BaseFSAPIsTests, unittest.TestCase):
@unittest.skipIf(PYPY and TRAVIS, "unreliable on PYPY + TRAVIS")
@unittest.skipIf(MACOS and TRAVIS, "unreliable on TRAVIS") # TODO
@unittest.skipIf(PYPY, "unreliable on PYPY")
-@unittest.skipIf(not subprocess_supports_unicode(TESTFN_INVALID_UNICODE),
+@unittest.skipIf(not subprocess_supports_unicode(INVALID_UNICODE_SUFFIX),
"subprocess can't deal with invalid unicode")
class TestFSAPIsWithInvalidPath(_BaseFSAPIsTests, unittest.TestCase):
"""Test FS APIs with a funky, invalid path name."""
- funky_suffix = os.path.basename(TESTFN_INVALID_UNICODE)
+ funky_suffix = INVALID_UNICODE_SUFFIX
@classmethod
def expect_exact_path_match(cls):