diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-02-08 09:44:12 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-02-08 09:44:12 +0100 |
commit | 1547524a7563f3b78999d12f55b6cc6c3aeb5b6a (patch) | |
tree | e8f8ec12dadc3c2777d15dc8830468fc69d457d0 | |
parent | 3f795f49f7951b9615f16f894141089073e7b641 (diff) | |
download | psutil-1547524a7563f3b78999d12f55b6cc6c3aeb5b6a.tar.gz |
fix tox tests
-rw-r--r-- | psutil/tests/__init__.py | 3 | ||||
-rw-r--r-- | psutil/tests/test_bsd.py | 4 | ||||
-rw-r--r-- | psutil/tests/test_linux.py | 5 | ||||
-rw-r--r-- | psutil/tests/test_memory_leaks.py | 4 | ||||
-rw-r--r-- | psutil/tests/test_misc.py | 6 | ||||
-rw-r--r-- | psutil/tests/test_osx.py | 4 | ||||
-rw-r--r-- | psutil/tests/test_posix.py | 4 | ||||
-rw-r--r-- | psutil/tests/test_process.py | 22 | ||||
-rw-r--r-- | psutil/tests/test_sunos.py | 4 | ||||
-rw-r--r-- | psutil/tests/test_system.py | 5 | ||||
-rw-r--r-- | psutil/tests/test_windows.py | 6 | ||||
-rw-r--r-- | tox.ini | 3 |
12 files changed, 38 insertions, 32 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 71970bab..8adbcc5b 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -81,6 +81,7 @@ DEVNULL = open(os.devnull, 'r+') TESTFN = os.path.join(os.getcwd(), "$testfile") TESTFN_UNICODE = TESTFN + "ƒőő" TESTFILE_PREFIX = 'psutil-test-suite-' +TOX = os.getenv('TOX') or '' in ('1', 'true') if not PY3: try: TESTFN_UNICODE = unicode(TESTFN_UNICODE, sys.getfilesystemencoding()) @@ -583,7 +584,7 @@ def decode_path(path): return path -def test_module_by_name(name): +def run_test_module_by_name(name): # testmodules = [os.path.splitext(x)[0] for x in os.listdir(HERE) # if x.endswith('.py') and x.startswith('test_')] name = os.path.splitext(os.path.basename(name))[0] diff --git a/psutil/tests/test_bsd.py b/psutil/tests/test_bsd.py index 5d93f314..7e8e747b 100644 --- a/psutil/tests/test_bsd.py +++ b/psutil/tests/test_bsd.py @@ -26,8 +26,8 @@ from psutil.tests import get_test_subprocess from psutil.tests import MEMORY_TOLERANCE from psutil.tests import reap_children from psutil.tests import retry_before_failing +from psutil.tests import run_test_module_by_name from psutil.tests import sh -from psutil.tests import test_module_by_name from psutil.tests import unittest from psutil.tests import which @@ -295,4 +295,4 @@ class OpenBSDSpecificTestCase(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 3ad27fbf..bafd9007 100644 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -27,7 +27,6 @@ except ImportError: import mock # requires "pip install mock" import psutil -import psutil._pslinux from psutil import LINUX from psutil._compat import PY3 from psutil._compat import u @@ -38,13 +37,13 @@ from psutil.tests import MEMORY_TOLERANCE from psutil.tests import pyrun from psutil.tests import reap_children from psutil.tests import retry_before_failing +from psutil.tests import run_test_module_by_name from psutil.tests import sh from psutil.tests import skip_on_not_implemented from psutil.tests import TESTFN from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import which -from psutil.tests import test_module_by_name HERE = os.path.abspath(os.path.dirname(__file__)) @@ -619,4 +618,4 @@ class LinuxSpecificTestCase(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_memory_leaks.py b/psutil/tests/test_memory_leaks.py index 9f7725fe..9167742b 100644 --- a/psutil/tests/test_memory_leaks.py +++ b/psutil/tests/test_memory_leaks.py @@ -33,8 +33,8 @@ from psutil._compat import xrange from psutil.tests import get_test_subprocess from psutil.tests import reap_children from psutil.tests import RLIMIT_SUPPORT +from psutil.tests import run_test_module_by_name from psutil.tests import safe_remove -from psutil.tests import test_module_by_name from psutil.tests import TESTFN from psutil.tests import TRAVIS from psutil.tests import unittest @@ -444,4 +444,4 @@ class TestModuleFunctionsLeaks(Base): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index 92326d43..2126b4bf 100644 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -26,8 +26,9 @@ from psutil.tests import EXAMPLES_DIR from psutil.tests import importlib from psutil.tests import mock from psutil.tests import ROOT_DIR +from psutil.tests import run_test_module_by_name from psutil.tests import sh -from psutil.tests import test_module_by_name +from psutil.tests import TOX from psutil.tests import TRAVIS from psutil.tests import unittest @@ -316,6 +317,7 @@ class TestMisc(unittest.TestCase): # --- Example script tests # =================================================================== +@unittest.skipIf(TOX, "can't test on tox") class TestExampleScripts(unittest.TestCase): """Tests for scripts in the examples directory.""" @@ -416,4 +418,4 @@ class TestExampleScripts(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_osx.py b/psutil/tests/test_osx.py index 192f960f..37547c0c 100644 --- a/psutil/tests/test_osx.py +++ b/psutil/tests/test_osx.py @@ -19,8 +19,8 @@ from psutil.tests import get_test_subprocess from psutil.tests import MEMORY_TOLERANCE from psutil.tests import reap_children from psutil.tests import retry_before_failing +from psutil.tests import run_test_module_by_name from psutil.tests import sh -from psutil.tests import test_module_by_name from psutil.tests import TRAVIS from psutil.tests import unittest @@ -190,4 +190,4 @@ class OSXSpecificTestCase(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index a30a2510..0c2c5da1 100644 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -25,9 +25,9 @@ from psutil.tests import get_test_subprocess from psutil.tests import PYTHON from psutil.tests import reap_children from psutil.tests import retry_before_failing +from psutil.tests import run_test_module_by_name from psutil.tests import sh from psutil.tests import skip_on_access_denied -from psutil.tests import test_module_by_name from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import wait_for_pid @@ -272,4 +272,4 @@ class PosixSpecificTestCase(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 82ac1c91..c1295445 100644 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -68,15 +68,16 @@ from psutil.tests import pyrun from psutil.tests import PYTHON from psutil.tests import reap_children from psutil.tests import RLIMIT_SUPPORT +from psutil.tests import run_test_module_by_name from psutil.tests import safe_remove from psutil.tests import safe_rmdir from psutil.tests import sh from psutil.tests import skip_on_access_denied from psutil.tests import skip_on_not_implemented -from psutil.tests import test_module_by_name from psutil.tests import TESTFILE_PREFIX from psutil.tests import TESTFN from psutil.tests import ThreadTask +from psutil.tests import TOX from psutil.tests import TRAVIS from psutil.tests import unittest from psutil.tests import VALID_PROC_STATUSES @@ -1431,18 +1432,19 @@ class TestProcess(unittest.TestCase): d = p.environ() d2 = os.environ.copy() + removes = [] if OSX: - for key in ( + removes.extend([ "__CF_USER_TEXT_ENCODING", "VERSIONER_PYTHON_PREFER_32_BIT", - "VERSIONER_PYTHON_VERSION", - ): - d.pop(key, None) - d2.pop(key, None) + "VERSIONER_PYTHON_VERSION"]) if LINUX: - for key in ('PLAT', ): - d.pop(key, None) - d2.pop(key, None) + removes.extend(['PLAT']) + if TOX: + removes.extend(['HOME']) + for key in removes: + d.pop(key, None) + d2.pop(key, None) self.assertEqual(d, d2) @@ -1983,4 +1985,4 @@ class TestNonUnicode(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_sunos.py b/psutil/tests/test_sunos.py index 6a6bdc27..2afc8776 100644 --- a/psutil/tests/test_sunos.py +++ b/psutil/tests/test_sunos.py @@ -10,8 +10,8 @@ import os import psutil from psutil import SUNOS +from psutil.tests import run_test_module_by_name from psutil.tests import sh -from psutil.tests import test_module_by_name from psutil.tests import unittest @@ -38,4 +38,4 @@ class SunOSSpecificTestCase(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index e1129a65..b1e67d3f 100644 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -25,6 +25,7 @@ from psutil import OSX from psutil import POSIX from psutil import SUNOS from psutil import WINDOWS +from psutil._compat import long from psutil.tests import AF_INET6 from psutil.tests import APPVEYOR from psutil.tests import check_ip_address @@ -34,10 +35,10 @@ from psutil.tests import get_test_subprocess from psutil.tests import mock from psutil.tests import reap_children from psutil.tests import retry_before_failing +from psutil.tests import run_test_module_by_name from psutil.tests import safe_remove from psutil.tests import safe_rmdir from psutil.tests import skip_on_access_denied -from psutil.tests import test_module_by_name from psutil.tests import TESTFN from psutil.tests import TESTFN_UNICODE from psutil.tests import TRAVIS @@ -646,4 +647,4 @@ class TestSystemAPIs(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py index 4af65aca..dcc91278 100644 --- a/psutil/tests/test_windows.py +++ b/psutil/tests/test_windows.py @@ -34,11 +34,11 @@ from psutil._compat import long from psutil._compat import PY3 from psutil.tests import APPVEYOR from psutil.tests import get_test_subprocess +from psutil.tests import mock from psutil.tests import reap_children from psutil.tests import retry_before_failing -from psutil.tests import test_module_by_name +from psutil.tests import run_test_module_by_name from psutil.tests import unittest -from psutil.tests import mock cext = psutil._psplatform.cext @@ -577,4 +577,4 @@ class RemoteProcessTestCase(unittest.TestCase): if __name__ == '__main__': - test_module_by_name(__file__) + run_test_module_by_name(__file__) @@ -5,7 +5,7 @@ # directory. [tox] -envlist = py26, py27, py32, py33, py34 +envlist = py26, py27, py32, py33, py34, py35 [testenv] deps = @@ -22,6 +22,7 @@ deps = setenv = PYTHONPATH = {toxinidir}/test + TOX = 1 commands = py.test {posargs} |