From e4d0aa990d1c8802b262a1af4c23af47922ff89b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 6 Jan 2015 16:16:11 +0100 Subject: fix #570: test_memory_leaks test for error conditions --- test/test_memory_leaks.py | 27 ++++++++++++++++++++++----- test/test_psutil.py | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/test/test_memory_leaks.py b/test/test_memory_leaks.py index 614a82c6..3fbd8289 100644 --- a/test/test_memory_leaks.py +++ b/test/test_memory_leaks.py @@ -85,6 +85,10 @@ class Base(unittest.TestCase): self.fail("rss2=%s, rss3=%s, difference=%s" % (rss2, rss3, difference)) + def execute_w_exc(self, exc, function, *args, **kwargs): + kwargs['_exc'] = exc + self.execute(function, *args, **kwargs) + def get_mem(self): return psutil.Process().memory_info()[0] @@ -102,11 +106,15 @@ class TestProcessObjectLeaks(Base): reap_children() def call(self, function, *args, **kwargs): - try: - meth = getattr(self.proc, function) - meth(*args, **kwargs) - except psutil.Error: - pass + meth = getattr(self.proc, function) + if '_exc' in kwargs: + exc = kwargs.pop('_exc') + self.assertRaises(exc, meth, *args, **kwargs) + else: + try: + meth(*args, **kwargs) + except psutil.Error: + pass @skip_if_linux() def test_name(self): @@ -158,6 +166,7 @@ class TestProcessObjectLeaks(Base): self.execute('ionice', value) else: self.execute('ionice', psutil.IOPRIO_CLASS_NONE) + self.execute_w_exc(OSError, 'ionice', -1) @unittest.skipIf(OSX, "feature not supported on this platform") @skip_if_linux() @@ -225,6 +234,7 @@ class TestProcessObjectLeaks(Base): def test_cpu_affinity_set(self): affinity = psutil.Process().cpu_affinity() self.execute('cpu_affinity', affinity) + self.execute_w_exc(ValueError, 'cpu_affinity', [9999]) @skip_if_linux() def test_open_files(self): @@ -250,6 +260,7 @@ class TestProcessObjectLeaks(Base): def test_rlimit_set(self): limit = psutil.Process().rlimit(psutil.RLIMIT_NOFILE) self.execute('rlimit', psutil.RLIMIT_NOFILE, limit) + self.execute_w_exc(OSError, 'rlimit', -1) @skip_if_linux() # Windows implementation is based on a single system-wide function @@ -300,6 +311,12 @@ class TestProcessObjectLeaksZombie(TestProcessObjectLeaks): """ proc = DEAD_PROC + def call(self, *args, **kwargs): + try: + TestProcessObjectLeaks.call(self, *args, **kwargs) + except psutil.NoSuchProcess: + pass + if not POSIX: def test_kill(self): self.execute('kill') diff --git a/test/test_psutil.py b/test/test_psutil.py index 67fe80bc..c8e14e87 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -968,6 +968,7 @@ class TestSystemAPIs(unittest.TestCase): self.assertIn(mount, mounts) psutil.disk_usage(mount) + @skip_on_access_denied() def test_net_connections(self): def check(cons, families, types_): for conn in cons: -- cgit v1.2.1 From 97fba78f6b8bf39176ea98188f668f761b1d1281 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 6 Jan 2015 16:25:14 +0100 Subject: attempt to fix travis failure --- test/test_memory_leaks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_memory_leaks.py b/test/test_memory_leaks.py index 3fbd8289..7119a515 100644 --- a/test/test_memory_leaks.py +++ b/test/test_memory_leaks.py @@ -25,7 +25,7 @@ else: import psutil import psutil._common -from psutil._compat import callable, xrange +from psutil._compat import xrange from test_psutil import (WINDOWS, POSIX, OSX, LINUX, SUNOS, BSD, TESTFN, RLIMIT_SUPPORT) from test_psutil import (reap_children, supports_ipv6, safe_remove, @@ -234,7 +234,7 @@ class TestProcessObjectLeaks(Base): def test_cpu_affinity_set(self): affinity = psutil.Process().cpu_affinity() self.execute('cpu_affinity', affinity) - self.execute_w_exc(ValueError, 'cpu_affinity', [9999]) + self.execute_w_exc(ValueError, 'cpu_affinity', [-1]) @skip_if_linux() def test_open_files(self): -- cgit v1.2.1 From d5d3fd493640959977aec0a8e99a821ea65c712d Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 6 Jan 2015 16:29:04 +0100 Subject: attempt to fix travis failure --- test/test_memory_leaks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_memory_leaks.py b/test/test_memory_leaks.py index 7119a515..be346269 100644 --- a/test/test_memory_leaks.py +++ b/test/test_memory_leaks.py @@ -27,7 +27,7 @@ import psutil._common from psutil._compat import xrange from test_psutil import (WINDOWS, POSIX, OSX, LINUX, SUNOS, BSD, TESTFN, - RLIMIT_SUPPORT) + RLIMIT_SUPPORT, TRAVIS) from test_psutil import (reap_children, supports_ipv6, safe_remove, get_test_subprocess) @@ -234,7 +234,8 @@ class TestProcessObjectLeaks(Base): def test_cpu_affinity_set(self): affinity = psutil.Process().cpu_affinity() self.execute('cpu_affinity', affinity) - self.execute_w_exc(ValueError, 'cpu_affinity', [-1]) + if not TRAVIS: + self.execute_w_exc(ValueError, 'cpu_affinity', [-1]) @skip_if_linux() def test_open_files(self): -- cgit v1.2.1 From ea6e3d7cbc47e6b49b7cbff83575fe7254dc8a4d Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 6 Jan 2015 07:30:12 -0800 Subject: windows: remove last python 2.4/2.5 references from make.bat; update dates --- HISTORY.rst | 2 +- README.rst | 1 + make.bat | 7 +------ 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 334c7623..e053b8d5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,6 @@ Bug tracker at https://github.com/giampaolo/psutil/issues -2.2.0 - XXXX-XX-XX +2.2.0 - 2015-01-06 ================== **Enhancements** diff --git a/README.rst b/README.rst index 405785ca..3a218705 100644 --- a/README.rst +++ b/README.rst @@ -320,6 +320,7 @@ http://groups.google.com/group/psutil/ Timeline ======== +- 2015-01-06: `psutil-2.2.0.tar.gz `_ - 2014-09-26: `psutil-2.1.3.tar.gz `_ - 2014-09-21: `psutil-2.1.2.tar.gz `_ - 2014-04-30: `psutil-2.1.1.tar.gz `_ diff --git a/make.bat b/make.bat index 24e5c7e3..febf7d2f 100644 --- a/make.bat +++ b/make.bat @@ -41,9 +41,9 @@ if "%1" == "help" ( echo build-wheels create wheel installers in dist directory echo clean clean build files echo install compile and install - echo memtest run memory leak tests echo setup-env install pip, unittest2, wheels for all python versions echo test run tests + echo test-memleaks run memory leak tests echo test-process run process related tests echo test-system run system APIs related tests echo uninstall uninstall @@ -132,9 +132,6 @@ if "%1" == "test-memleaks" ( if "%1" == "build-exes" ( :build-exes - rem mingw 32 versions - C:\Python24\python.exe setup.py build -c mingw32 bdist_wininst || goto :error - C:\Python25\python.exe setup.py build -c mingw32 bdist_wininst || goto :error rem "standard" 32 bit versions, using VS 2008 (2.6, 2.7) or VS 2010 (3.3+) C:\Python26\python.exe setup.py build bdist_wininst || goto :error C:\Python27\python.exe setup.py build bdist_wininst || goto :error @@ -154,8 +151,6 @@ if "%1" == "build-exes" ( if "%1" == "upload-exes" ( :upload-exes - rem mingw 32 versions - C:\Python25\python.exe setup.py build -c mingw32 bdist_wininst upload || goto :error rem "standard" 32 bit versions, using VS 2008 (2.6, 2.7) or VS 2010 (3.3+) C:\Python26\python.exe setup.py bdist_wininst upload || goto :error C:\Python27\python.exe setup.py bdist_wininst upload || goto :error -- cgit v1.2.1 From 2bc8555f0428af81c2d067aa76168ed7bc5e0179 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 6 Jan 2015 16:38:25 +0100 Subject: remove last python 2.4/2.5 references --- make.bat | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/make.bat b/make.bat index febf7d2f..4520a989 100644 --- a/make.bat +++ b/make.bat @@ -14,7 +14,7 @@ rem rem By default C:\Python27\python.exe is used. rem To compile for a specific Python version run: rem -rem set PYTHON=C:\Python24\python.exe & make.bat build +rem set PYTHON=C:\Python26\python.exe & make.bat build rem rem ========================================================================== @@ -68,26 +68,14 @@ if "%1" == "clean" ( if "%1" == "build" ( :build - if %PYTHON%==C:\Python24\python.exe ( - %PYTHON% setup.py build -c mingw32 - ) else if %PYTHON%==C:\Python25\python.exe ( - %PYTHON% setup.py build -c mingw32 - ) else ( - %PYTHON% setup.py build - ) + %PYTHON% setup.py build if %errorlevel% neq 0 goto :error goto :eof ) if "%1" == "install" ( :install - if %PYTHON%==C:\Python24\python.exe ( - %PYTHON% setup.py build -c mingw32 install - ) else if %PYTHON%==C:\Python25\python.exe ( - %PYTHON% setup.py build -c mingw32 install - ) else ( - %PYTHON% setup.py build install - ) + %PYTHON% setup.py build install goto :eof ) -- cgit v1.2.1 From 7e82dd32c9df5be2e72993209d031babd48219c9 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Thu, 8 Jan 2015 10:52:34 -0700 Subject: Modules aren't scripts. They shouldn't have shebang lines. --- psutil/__init__.py | 1 - psutil/_compat.py | 2 -- psutil/_psbsd.py | 2 -- psutil/_pslinux.py | 2 -- psutil/_psosx.py | 2 -- psutil/_psposix.py | 2 -- psutil/_pssunos.py | 2 -- psutil/_pswindows.py | 2 -- 8 files changed, 15 deletions(-) diff --git a/psutil/__init__.py b/psutil/__init__.py index ecc936d4..8d5ba5d6 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. diff --git a/psutil/_compat.py b/psutil/_compat.py index 84fd9ca8..203408b8 100644 --- a/psutil/_compat.py +++ b/psutil/_compat.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 87ae2119..39dfea36 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 3bf062b1..71ab8824 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/psutil/_psosx.py b/psutil/_psosx.py index c40ef1d7..733a1854 100644 --- a/psutil/_psosx.py +++ b/psutil/_psosx.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/psutil/_psposix.py b/psutil/_psposix.py index 94db351e..0da6a8ce 100644 --- a/psutil/_psposix.py +++ b/psutil/_psposix.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index 7b5385ef..1ee249e5 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 6068446b..47c049c1 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -- cgit v1.2.1