summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-02-10 13:47:33 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2016-02-10 13:47:33 -0800
commit069a8815ce6f69a37130aa3cb7fd3acf6a791441 (patch)
treea352076a499cd38cea839c4c2090f039256cac74
parent837a54ad59bc21151f92ba9d6aaa840c51f52d40 (diff)
downloadpsutil-069a8815ce6f69a37130aa3cb7fd3acf6a791441.tar.gz
fix #763: fix unicode tests on Windows
-rw-r--r--psutil/tests/test_process.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index a0c88911..83f5b549 100644
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -1888,10 +1888,15 @@ class TestUnicode(unittest.TestCase):
env['FUNNY_ARG'] = self.uexe
sproc = get_test_subprocess(env=env)
p = psutil.Process(sproc.pid)
- self.assertEqual(p.environ()['FUNNY_ARG'], self.uexe)
+ if PY3:
+ self.assertEqual(p.environ()['FUNNY_ARG'], self.uexe)
+ else:
+ self.assertEqual(p.environ()['FUNNY_ARG'],
+ self.uexe.decode(sys.getfilesystemencoding()))
def test_disk_usage(self):
- psutil.disk_usage(self.uexe)
+ path = tempfile.mkdtemp(prefix='psutil', suffix='รจ')
+ psutil.disk_usage(path)
class TestNonUnicode(unittest.TestCase):
@@ -1995,17 +2000,26 @@ class TestNonUnicode(unittest.TestCase):
def test_proc_environ(self):
env = os.environ.copy()
- env['FUNNY_ARG'] = self.temp_directory
+ funny_path = self.temp_directory
+ # ...otherwise subprocess.Popen fails with TypeError (it
+ # wants a string)
+ env['FUNNY_ARG'] = \
+ decode_path(funny_path) if WINDOWS and PY3 else funny_path
sproc = get_test_subprocess(env=env)
p = psutil.Process(sproc.pid)
self.assertEqual(
- encode_path(p.environ()['FUNNY_ARG']), self.temp_directory)
+ encode_path(p.environ()['FUNNY_ARG']), funny_path)
def test_disk_usage(self):
funny_directory = os.path.realpath(
os.path.join(self.temp_directory, b"\xc0\x80"))
os.mkdir(funny_directory)
self.addCleanup(safe_rmdir, funny_directory)
+ if WINDOWS and PY3:
+ # Python 3 on Windows is moving towards accepting unicode
+ # paths only:
+ # http://bugs.python.org/issue26330
+ funny_directory = decode_path(funny_directory)
psutil.disk_usage(funny_directory)