From 7e8f4f490bcc4b19e4194e8ae75984207eb33426 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 22 Jan 2016 16:41:38 +0100 Subject: fix tests: +x bit was not set on exe test file --- HISTORY.rst | 6 ++++-- test/test_psutil.py | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index cdbe95bf..206238f4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,8 +11,10 @@ Bug tracker at https://github.com/giampaolo/psutil/issues **Bug fixes** -- #734: [Linux] process name() and exe() can fail on Python 3 if string - contains non-UTF8 charaters. (patch by Frank Benkstein) +- #734: [Linux] non unicode data not correctly handled in Python 3 for process + name() and exe(). +- #734: [OSX] non unicode data not correctly handled in Python 3 for process + cwd(), exe(), open_files(). 3.4.2 - 2016-01-20 diff --git a/test/test_psutil.py b/test/test_psutil.py index 84bccd6b..1bff2064 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -3282,13 +3282,17 @@ class TestNonUnicode(unittest.TestCase): tearDown = setUp + def copy_file(self, src, dst): + # A wrapper around shutil.copy() which is broken on py < 3.4 + # when passed bytes paths. + with open(src, 'rb') as input_: + with open(dst, 'wb') as output: + output.write(input_.read()) + shutil.copymode(src, dst) + def test_proc_exe(self): funny_executable = os.path.join(self.temp_directory, b"\xc0\x80") - # This is broken on py 3.3, hence the manual copy - # shutil.copy(self.test_executable, funny_executable) - with open(self.test_executable, 'rb') as input: - with open(funny_executable, 'wb') as output: - output.write(input.read()) + self.copy_file(self.test_executable, funny_executable) self.addCleanup(safe_remove, funny_executable) subp = get_test_subprocess(cmd=[decode_path(funny_executable)], stdin=subprocess.PIPE, @@ -3302,11 +3306,7 @@ class TestNonUnicode(unittest.TestCase): def test_proc_name(self): funny_executable = os.path.join(self.temp_directory, b"\xc0\x80") - # This is broken on py 3.3, hence the manual copy - # shutil.copy(self.test_executable, funny_executable) - with open(self.test_executable, 'rb') as input: - with open(funny_executable, 'wb') as output: - output.write(input.read()) + self.copy_file(self.test_executable, funny_executable) self.addCleanup(safe_remove, funny_executable) subp = get_test_subprocess(cmd=[decode_path(funny_executable)], stdin=subprocess.PIPE, -- cgit v1.2.1