summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.ci/travis/run.sh6
-rw-r--r--.coveragerc2
-rw-r--r--DEVGUIDE.rst15
-rw-r--r--MANIFEST.in34
-rw-r--r--Makefile22
-rw-r--r--appveyor.yml16
-rw-r--r--docs/index.rst7
-rwxr-xr-xscripts/internal/winmake.py14
-rwxr-xr-xsetup.py4
-rw-r--r--tests/README.rst (renamed from psutil/tests/README.rst)9
-rw-r--r--tests/__init__.py (renamed from psutil/tests/__init__.py)4
-rwxr-xr-xtests/__main__.py (renamed from psutil/tests/__main__.py)12
-rwxr-xr-xtests/test_aix.py (renamed from psutil/tests/test_aix.py)12
-rwxr-xr-xtests/test_bsd.py (renamed from psutil/tests/test_bsd.py)18
-rwxr-xr-xtests/test_connections.py (renamed from psutil/tests/test_connections.py)40
-rwxr-xr-xtests/test_contracts.py (renamed from psutil/tests/test_contracts.py)32
-rwxr-xr-xtests/test_linux.py (renamed from psutil/tests/test_linux.py)40
-rwxr-xr-xtests/test_memory_leaks.py (renamed from psutil/tests/test_memory_leaks.py)40
-rwxr-xr-xtests/test_misc.py (renamed from psutil/tests/test_misc.py)96
-rwxr-xr-xtests/test_osx.py (renamed from psutil/tests/test_osx.py)18
-rwxr-xr-xtests/test_posix.py (renamed from psutil/tests/test_posix.py)28
-rwxr-xr-xtests/test_process.py (renamed from psutil/tests/test_process.py)68
-rwxr-xr-xtests/test_sunos.py (renamed from psutil/tests/test_sunos.py)6
-rwxr-xr-xtests/test_system.py (renamed from psutil/tests/test_system.py)40
-rwxr-xr-xtests/test_unicode.py (renamed from psutil/tests/test_unicode.py)44
-rwxr-xr-xtests/test_windows.py (renamed from psutil/tests/test_windows.py)18
-rw-r--r--tox.ini2
27 files changed, 316 insertions, 331 deletions
diff --git a/.ci/travis/run.sh b/.ci/travis/run.sh
index 1501387a..6660bf53 100755
--- a/.ci/travis/run.sh
+++ b/.ci/travis/run.sh
@@ -20,14 +20,14 @@ python setup.py develop
# run tests (with coverage)
if [[ $PYVER == '2.7' ]] && [[ "$(uname -s)" != 'Darwin' ]]; then
- PSUTIL_TESTING=1 python -Wa -m coverage run psutil/tests/__main__.py
+ PSUTIL_TESTING=1 python -Wa -m coverage run tests/__main__.py
else
- PSUTIL_TESTING=1 python -Wa psutil/tests/__main__.py
+ PSUTIL_TESTING=1 python -Wa tests/__main__.py
fi
if [ "$PYVER" == "2.7" ] || [ "$PYVER" == "3.6" ]; then
# run mem leaks test
- PSUTIL_TESTING=1 python -Wa psutil/tests/test_memory_leaks.py
+ PSUTIL_TESTING=1 python -Wa tests/test_memory_leaks.py
# run linter (on Linux only)
if [[ "$(uname -s)" != 'Darwin' ]]; then
python -m flake8
diff --git a/.coveragerc b/.coveragerc
index 7d3f185f..28316cfb 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -4,7 +4,7 @@ include =
*psutil*
omit =
psutil/_compat.py
- psutil/tests/*
+ tests/*
setup.py
exclude_lines =
enum.IntEnum
diff --git a/DEVGUIDE.rst b/DEVGUIDE.rst
index 2d48ced2..df4c9cbb 100644
--- a/DEVGUIDE.rst
+++ b/DEVGUIDE.rst
@@ -99,8 +99,8 @@ Usually the files involved when adding a new functionality are:
psutil/_ps{platform}.py # python platform wrapper
psutil/_psutil_{platform}.c # C platform extension
psutil/_psutil_{platform}.h # C header file
- psutil/tests/test_process|system.py # main test suite
- psutil/tests/test_{platform}.py # platform specific test suite
+ tests/test_process|system.py # main test suite
+ tests/test_{platform}.py # platform specific test suite
Typical process occurring when adding a new functionality (API):
@@ -109,12 +109,11 @@ Typical process occurring when adding a new functionality (API):
(e.g. ``psutil/_pslinux.py``).
- if the change requires C, write the C implementation in
``psutil/_psutil_{platform}.c`` (e.g. ``psutil/_psutil_linux.c``).
-- write a generic test in ``psutil/tests/test_system.py`` or
- ``psutil/tests/test_process.py``.
-- if possible, write a platform specific test in
- ``psutil/tests/test_{platform}.py`` (e.g. ``test_linux.py``).
- This usually means testing the return value of the new feature against
- a system CLI tool.
+- write a generic test in ``tests/test_system.py`` or
+ ``tests/test_process.py``.
+- if possible, write a platform specific test in ``tests/test_{platform}.py``
+ (e.g. ``test_linux.py``). This usually means testing the return value of the
+ new feature against a system CLI tool.
- update doc in ``doc/index.py``.
- update ``HISTORY.rst``.
- update ``README.rst`` (if necessary).
diff --git a/MANIFEST.in b/MANIFEST.in
index 7a92a4e5..c422be86 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -79,23 +79,6 @@ include psutil/arch/windows/security.c
include psutil/arch/windows/security.h
include psutil/arch/windows/services.c
include psutil/arch/windows/services.h
-include psutil/tests/README.rst
-include psutil/tests/__init__.py
-include psutil/tests/__main__.py
-include psutil/tests/test_aix.py
-include psutil/tests/test_bsd.py
-include psutil/tests/test_connections.py
-include psutil/tests/test_contracts.py
-include psutil/tests/test_linux.py
-include psutil/tests/test_memory_leaks.py
-include psutil/tests/test_misc.py
-include psutil/tests/test_osx.py
-include psutil/tests/test_posix.py
-include psutil/tests/test_process.py
-include psutil/tests/test_sunos.py
-include psutil/tests/test_system.py
-include psutil/tests/test_unicode.py
-include psutil/tests/test_windows.py
include scripts/battery.py
include scripts/cpu_distribution.py
include scripts/disk_usage.py
@@ -128,4 +111,21 @@ include scripts/top.py
include scripts/who.py
include scripts/winservices.py
include setup.py
+include tests/README.rst
+include tests/__init__.py
+include tests/__main__.py
+include tests/test_aix.py
+include tests/test_bsd.py
+include tests/test_connections.py
+include tests/test_contracts.py
+include tests/test_linux.py
+include tests/test_memory_leaks.py
+include tests/test_misc.py
+include tests/test_osx.py
+include tests/test_posix.py
+include tests/test_process.py
+include tests/test_sunos.py
+include tests/test_system.py
+include tests/test_unicode.py
+include tests/test_windows.py
include tox.ini
diff --git a/Makefile b/Makefile
index 5081a4ed..99355233 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
# You can set the variables below from the command line.
PYTHON = python
-TSCRIPT = psutil/tests/__main__.py
+TSCRIPT = tests/__main__.py
ARGS =
# List of nice-to-have dev libs.
DEPS = \
@@ -113,41 +113,41 @@ test: ## Run all tests.
test-process: ## Run process-related API tests.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) -m unittest -v psutil.tests.test_process
+ $(TEST_PREFIX) $(PYTHON) -m unittest -v tests.test_process
test-system: ## Run system-related API tests.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) -m unittest -v psutil.tests.test_system
+ $(TEST_PREFIX) $(PYTHON) -m unittest -v tests.test_system
test-misc: ## Run miscellaneous tests.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_misc.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_misc.py
test-unicode: ## Test APIs dealing with strings.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_unicode.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_unicode.py
test-contracts: ## APIs sanity tests.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_contracts.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_contracts.py
test-connections: ## Test net_connections() and Process.connections().
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_connections.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_connections.py
test-posix: ## POSIX specific tests.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_posix.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_posix.py
test-platform: ## Run specific platform tests only.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py
test-memleaks: ## Memory leak tests.
${MAKE} install
- $(TEST_PREFIX) $(PYTHON) psutil/tests/test_memory_leaks.py
+ $(TEST_PREFIX) $(PYTHON) tests/test_memory_leaks.py
-test-by-name: ## e.g. make test-by-name ARGS=psutil.tests.test_system.TestSystemAPIs
+test-by-name: ## e.g. make test-by-name ARGS=tests.test_system.TestSystemAPIs
${MAKE} install
@$(TEST_PREFIX) $(PYTHON) -m unittest -v $(ARGS)
diff --git a/appveyor.yml b/appveyor.yml
index 28f5f7f6..2ceb63f7 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -83,7 +83,7 @@ build: off
test_script:
- "%WITH_COMPILER% %PYTHON%/python -V"
- - "set PYTHONWARNINGS=all && set PSUTIL_TESTING=1 && set PSUTIL_DEBUG=1 && %WITH_COMPILER% %PYTHON%/python psutil/tests/__main__.py"
+ - "set PYTHONWARNINGS=all && set PSUTIL_TESTING=1 && set PSUTIL_DEBUG=1 && %WITH_COMPILER% %PYTHON%/python tests/__main__.py"
after_test:
- "%WITH_COMPILER% %PYTHON%/python setup.py bdist_wheel"
@@ -112,12 +112,12 @@ only_commits:
psutil/_psutil_windows.*
psutil/_pswindows.py
psutil/arch/windows/*
- psutil/tests/__init__.py
- psutil/tests/__main__.py
- psutil/tests/test_memory_leaks.py
- psutil/tests/test_misc.py
- psutil/tests/test_process.py
- psutil/tests/test_system.py
- psutil/tests/test_windows.py
+ tests/__init__.py
+ tests/__main__.py
+ tests/test_memory_leaks.py
+ tests/test_misc.py
+ tests/test_process.py
+ tests/test_system.py
+ tests/test_windows.py
scripts/*
setup.py
diff --git a/docs/index.rst b/docs/index.rst
index 4f77b2e4..5ea03ab8 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -2605,12 +2605,7 @@ FAQs
Running tests
=============
-There are two ways of running tests. If psutil is already installed use::
-
- $ python -m psutil.tests
-
-You can use this method as a quick way to make sure psutil fully works on your
-platform. If you have a copy of the source code you can also use::
+First, obtain a copy of the source code. Then run tests using the command::
$ make test
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py
index 548f7a8e..de58fbfc 100755
--- a/scripts/internal/winmake.py
+++ b/scripts/internal/winmake.py
@@ -355,7 +355,7 @@ def test_process():
"""Run process tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_process" % PYTHON)
+ sh("%s -m unittest -v tests.test_process" % PYTHON)
@cmd
@@ -363,7 +363,7 @@ def test_system():
"""Run system tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_system" % PYTHON)
+ sh("%s -m unittest -v tests.test_system" % PYTHON)
@cmd
@@ -371,7 +371,7 @@ def test_platform():
"""Run windows only tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_windows" % PYTHON)
+ sh("%s -m unittest -v tests.test_windows" % PYTHON)
@cmd
@@ -379,7 +379,7 @@ def test_misc():
"""Run misc tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_misc" % PYTHON)
+ sh("%s -m unittest -v tests.test_misc" % PYTHON)
@cmd
@@ -387,7 +387,7 @@ def test_unicode():
"""Run unicode tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_unicode" % PYTHON)
+ sh("%s -m unittest -v tests.test_unicode" % PYTHON)
@cmd
@@ -395,7 +395,7 @@ def test_connections():
"""Run connections tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_connections" % PYTHON)
+ sh("%s -m unittest -v tests.test_connections" % PYTHON)
@cmd
@@ -403,7 +403,7 @@ def test_contracts():
"""Run contracts tests"""
install()
test_setup()
- sh("%s -m unittest -v psutil.tests.test_contracts" % PYTHON)
+ sh("%s -m unittest -v tests.test_contracts" % PYTHON)
@cmd
diff --git a/setup.py b/setup.py
index 61056f5f..f03ab457 100755
--- a/setup.py
+++ b/setup.py
@@ -279,7 +279,7 @@ def main():
url='https://github.com/giampaolo/psutil',
platforms='Platform Independent',
license='BSD',
- packages=['psutil', 'psutil.tests'],
+ packages=['psutil'],
ext_modules=extensions,
# see: python setup.py register --list-classifiers
classifiers=[
@@ -327,7 +327,7 @@ def main():
if setuptools is not None:
kwargs.update(
python_requires=">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
- test_suite="psutil.tests.get_suite",
+ test_suite="tests.get_suite",
tests_require=[
'ipaddress; python_version < "3.3"',
'mock; python_version < "3.3"',
diff --git a/psutil/tests/README.rst b/tests/README.rst
index 515abf77..a02b8813 100644
--- a/psutil/tests/README.rst
+++ b/tests/README.rst
@@ -1,14 +1,7 @@
Instructions for running tests
==============================
-* There are two ways of running tests. As a "user", if psutil is already
- installed and you just want to test it works::
-
- python -m psutil.tests --install-deps # install test deps
- python -m psutil.tests
-
- As a "developer", if you have a copy of the source code and you whish to hack
- on psutil::
+* To run tests::
make setup-dev-env # install test deps (+ other things)
make test
diff --git a/psutil/tests/__init__.py b/tests/__init__.py
index 499240fb..f59cd846 100644
--- a/psutil/tests/__init__.py
+++ b/tests/__init__.py
@@ -142,7 +142,7 @@ ASCII_FS = sys.getfilesystemencoding().lower() in ('ascii', 'us-ascii')
# --- paths
-ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
+ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
SCRIPTS_DIR = os.path.join(ROOT_DIR, 'scripts')
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -788,7 +788,7 @@ def get_suite():
suite = unittest.TestSuite()
for tm in testmods:
# ...so that the full test paths are printed on screen
- tm = "psutil.tests.%s" % tm
+ tm = "tests.%s" % tm
suite.addTest(unittest.defaultTestLoader.loadTestsFromName(tm))
return suite
diff --git a/psutil/tests/__main__.py b/tests/__main__.py
index 62fe0742..97690afe 100755
--- a/psutil/tests/__main__.py
+++ b/tests/__main__.py
@@ -5,9 +5,7 @@
# found in the LICENSE file.
"""
-Run unit tests. This is invoked by:
-
-$ python -m psutil.tests
+Run unit tests.
"""
import contextlib
@@ -21,8 +19,8 @@ try:
except ImportError:
from urllib2 import urlopen
-from psutil.tests import PYTHON_EXE
-from psutil.tests import run_suite
+from tests import PYTHON_EXE
+from tests import run_suite
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -71,7 +69,7 @@ def install_test_deps(deps=None):
def main():
- usage = "%s -m psutil.tests [opts]" % PYTHON_EXE
+ usage = "%s -m tests [opts]" % PYTHON_EXE
parser = optparse.OptionParser(usage=usage, description="run unit tests")
parser.add_option("-i", "--install-deps",
action="store_true", default=False,
@@ -86,7 +84,7 @@ def main():
try:
__import__(dep.split("==")[0])
except ImportError:
- sys.exit("%r lib is not installed; run %s -m psutil.tests "
+ sys.exit("%r lib is not installed; run %s -m tests "
"--install-deps" % (dep, PYTHON_EXE))
run_suite()
diff --git a/psutil/tests/test_aix.py b/tests/test_aix.py
index 7a8a4c33..8370c383 100755
--- a/psutil/tests/test_aix.py
+++ b/tests/test_aix.py
@@ -11,9 +11,9 @@
import re
from psutil import AIX
-from psutil.tests import run_test_module_by_name
-from psutil.tests import sh
-from psutil.tests import unittest
+from tests import run_test_module_by_name
+from tests import sh
+from tests import unittest
import psutil
@@ -38,9 +38,9 @@ class AIXSpecificTestCase(unittest.TestCase):
psutil_result = psutil.virtual_memory()
- # MEMORY_TOLERANCE from psutil.tests is not enough. For some reason
- # we're seeing differences of ~1.2 MB. 2 MB is still a good tolerance
- # when compared to GBs.
+ # MEMORY_TOLERANCE from tests is not enough. For some reason we're
+ # seeing differences of ~1.2 MB. 2 MB is still a good tolerance when
+ # compared to GBs.
MEMORY_TOLERANCE = 2 * KB * KB # 2 MB
self.assertEqual(psutil_result.total, total)
self.assertAlmostEqual(
diff --git a/psutil/tests/test_bsd.py b/tests/test_bsd.py
index d3868ada..cc9c058d 100755
--- a/psutil/tests/test_bsd.py
+++ b/tests/test_bsd.py
@@ -20,15 +20,15 @@ from psutil import BSD
from psutil import FREEBSD
from psutil import NETBSD
from psutil import OPENBSD
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_BATTERY
-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 unittest
-from psutil.tests import which
+from tests import get_test_subprocess
+from tests import HAS_BATTERY
+from tests import MEMORY_TOLERANCE
+from tests import reap_children
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import sh
+from tests import unittest
+from tests import which
if BSD:
diff --git a/psutil/tests/test_connections.py b/tests/test_connections.py
index 176e2664..c61e0c2c 100755
--- a/psutil/tests/test_connections.py
+++ b/tests/test_connections.py
@@ -26,25 +26,25 @@ from psutil import SUNOS
from psutil import WINDOWS
from psutil._common import supports_ipv6
from psutil._compat import PY3
-from psutil.tests import AF_UNIX
-from psutil.tests import bind_socket
-from psutil.tests import bind_unix_socket
-from psutil.tests import check_connection_ntuple
-from psutil.tests import create_sockets
-from psutil.tests import get_free_port
-from psutil.tests import HAS_CONNECTIONS_UNIX
-from psutil.tests import pyrun
-from psutil.tests import reap_children
-from psutil.tests import run_test_module_by_name
-from psutil.tests import safe_rmpath
-from psutil.tests import skip_on_access_denied
-from psutil.tests import tcp_socketpair
-from psutil.tests import TESTFN
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
-from psutil.tests import unix_socket_path
-from psutil.tests import unix_socketpair
-from psutil.tests import wait_for_file
+from tests import AF_UNIX
+from tests import bind_socket
+from tests import bind_unix_socket
+from tests import check_connection_ntuple
+from tests import create_sockets
+from tests import get_free_port
+from tests import HAS_CONNECTIONS_UNIX
+from tests import pyrun
+from tests import reap_children
+from tests import run_test_module_by_name
+from tests import safe_rmpath
+from tests import skip_on_access_denied
+from tests import tcp_socketpair
+from tests import TESTFN
+from tests import TRAVIS
+from tests import unittest
+from tests import unix_socket_path
+from tests import unix_socketpair
+from tests import wait_for_file
thisproc = psutil.Process()
@@ -471,7 +471,7 @@ class TestSystemWideConnections(Base, unittest.TestCase):
fname = os.path.realpath(TESTFN) + str(i)
src = textwrap.dedent("""\
import time, os
- from psutil.tests import create_sockets
+ from tests import create_sockets
with create_sockets():
with open('%s', 'w') as f:
f.write(str(os.getpid()))
diff --git a/psutil/tests/test_contracts.py b/tests/test_contracts.py
index 0dfb3e2a..f07c2624 100755
--- a/psutil/tests/test_contracts.py
+++ b/tests/test_contracts.py
@@ -28,22 +28,22 @@ from psutil import POSIX
from psutil import SUNOS
from psutil import WINDOWS
from psutil._compat import long
-from psutil.tests import bind_unix_socket
-from psutil.tests import check_connection_ntuple
-from psutil.tests import get_kernel_version
-from psutil.tests import HAS_CONNECTIONS_UNIX
-from psutil.tests import HAS_RLIMIT
-from psutil.tests import HAS_SENSORS_FANS
-from psutil.tests import HAS_SENSORS_TEMPERATURES
-from psutil.tests import is_namedtuple
-from psutil.tests import run_test_module_by_name
-from psutil.tests import safe_rmpath
-from psutil.tests import skip_on_access_denied
-from psutil.tests import TESTFN
-from psutil.tests import unittest
-from psutil.tests import unix_socket_path
-from psutil.tests import VALID_PROC_STATUSES
-from psutil.tests import warn
+from tests import bind_unix_socket
+from tests import check_connection_ntuple
+from tests import get_kernel_version
+from tests import HAS_CONNECTIONS_UNIX
+from tests import HAS_RLIMIT
+from tests import HAS_SENSORS_FANS
+from tests import HAS_SENSORS_TEMPERATURES
+from tests import is_namedtuple
+from tests import run_test_module_by_name
+from tests import safe_rmpath
+from tests import skip_on_access_denied
+from tests import TESTFN
+from tests import unittest
+from tests import unix_socket_path
+from tests import VALID_PROC_STATUSES
+from tests import warn
import psutil
diff --git a/psutil/tests/test_linux.py b/tests/test_linux.py
index 6ba17b25..7cc5a01a 100755
--- a/psutil/tests/test_linux.py
+++ b/tests/test_linux.py
@@ -27,26 +27,26 @@ import psutil
from psutil import LINUX
from psutil._compat import PY3
from psutil._compat import u
-from psutil.tests import call_until
-from psutil.tests import HAS_BATTERY
-from psutil.tests import HAS_CPU_FREQ
-from psutil.tests import HAS_RLIMIT
-from psutil.tests import MEMORY_TOLERANCE
-from psutil.tests import mock
-from psutil.tests import PYPY
-from psutil.tests import pyrun
-from psutil.tests import reap_children
-from psutil.tests import reload_module
-from psutil.tests import retry_before_failing
-from psutil.tests import run_test_module_by_name
-from psutil.tests import safe_rmpath
-from psutil.tests import sh
-from psutil.tests import skip_on_not_implemented
-from psutil.tests import TESTFN
-from psutil.tests import ThreadTask
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
-from psutil.tests import which
+from tests import call_until
+from tests import HAS_BATTERY
+from tests import HAS_CPU_FREQ
+from tests import HAS_RLIMIT
+from tests import MEMORY_TOLERANCE
+from tests import mock
+from tests import PYPY
+from tests import pyrun
+from tests import reap_children
+from tests import reload_module
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import safe_rmpath
+from tests import sh
+from tests import skip_on_not_implemented
+from tests import TESTFN
+from tests import ThreadTask
+from tests import TRAVIS
+from tests import unittest
+from tests import which
HERE = os.path.abspath(os.path.dirname(__file__))
diff --git a/psutil/tests/test_memory_leaks.py b/tests/test_memory_leaks.py
index 680fe780..53723c7b 100755
--- a/psutil/tests/test_memory_leaks.py
+++ b/tests/test_memory_leaks.py
@@ -31,26 +31,26 @@ from psutil import POSIX
from psutil import SUNOS
from psutil import WINDOWS
from psutil._compat import xrange
-from psutil.tests import create_sockets
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_CPU_AFFINITY
-from psutil.tests import HAS_CPU_FREQ
-from psutil.tests import HAS_ENVIRON
-from psutil.tests import HAS_IONICE
-from psutil.tests import HAS_MEMORY_MAPS
-from psutil.tests import HAS_PROC_CPU_NUM
-from psutil.tests import HAS_PROC_IO_COUNTERS
-from psutil.tests import HAS_RLIMIT
-from psutil.tests import HAS_SENSORS_BATTERY
-from psutil.tests import HAS_SENSORS_FANS
-from psutil.tests import HAS_SENSORS_TEMPERATURES
-from psutil.tests import reap_children
-from psutil.tests import run_test_module_by_name
-from psutil.tests import safe_rmpath
-from psutil.tests import skip_on_access_denied
-from psutil.tests import TESTFN
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
+from tests import create_sockets
+from tests import get_test_subprocess
+from tests import HAS_CPU_AFFINITY
+from tests import HAS_CPU_FREQ
+from tests import HAS_ENVIRON
+from tests import HAS_IONICE
+from tests import HAS_MEMORY_MAPS
+from tests import HAS_PROC_CPU_NUM
+from tests import HAS_PROC_IO_COUNTERS
+from tests import HAS_RLIMIT
+from tests import HAS_SENSORS_BATTERY
+from tests import HAS_SENSORS_FANS
+from tests import HAS_SENSORS_TEMPERATURES
+from tests import reap_children
+from tests import run_test_module_by_name
+from tests import safe_rmpath
+from tests import skip_on_access_denied
+from tests import TESTFN
+from tests import TRAVIS
+from tests import unittest
LOOPS = 1000
diff --git a/psutil/tests/test_misc.py b/tests/test_misc.py
index 1d9067e7..3dbd49d1 100755
--- a/psutil/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -27,48 +27,48 @@ from psutil._common import memoize_when_activated
from psutil._common import supports_ipv6
from psutil._common import wrap_numbers
from psutil._compat import PY3
-from psutil.tests import APPVEYOR
-from psutil.tests import bind_socket
-from psutil.tests import bind_unix_socket
-from psutil.tests import call_until
-from psutil.tests import chdir
-from psutil.tests import create_proc_children_pair
-from psutil.tests import create_sockets
-from psutil.tests import create_zombie_proc
-from psutil.tests import DEVNULL
-from psutil.tests import get_free_port
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_BATTERY
-from psutil.tests import HAS_CONNECTIONS_UNIX
-from psutil.tests import HAS_MEMORY_FULL_INFO
-from psutil.tests import HAS_MEMORY_MAPS
-from psutil.tests import HAS_SENSORS_BATTERY
-from psutil.tests import HAS_SENSORS_FANS
-from psutil.tests import HAS_SENSORS_TEMPERATURES
-from psutil.tests import import_module_by_path
-from psutil.tests import is_namedtuple
-from psutil.tests import mock
-from psutil.tests import PYTHON_EXE
-from psutil.tests import reap_children
-from psutil.tests import reload_module
-from psutil.tests import retry
-from psutil.tests import ROOT_DIR
-from psutil.tests import run_test_module_by_name
-from psutil.tests import safe_mkdir
-from psutil.tests import safe_rmpath
-from psutil.tests import SCRIPTS_DIR
-from psutil.tests import sh
-from psutil.tests import tcp_socketpair
-from psutil.tests import TESTFN
-from psutil.tests import TOX
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
-from psutil.tests import unix_socket_path
-from psutil.tests import unix_socketpair
-from psutil.tests import wait_for_file
-from psutil.tests import wait_for_pid
+from tests import APPVEYOR
+from tests import bind_socket
+from tests import bind_unix_socket
+from tests import call_until
+from tests import chdir
+from tests import create_proc_children_pair
+from tests import create_sockets
+from tests import create_zombie_proc
+from tests import DEVNULL
+from tests import get_free_port
+from tests import get_test_subprocess
+from tests import HAS_BATTERY
+from tests import HAS_CONNECTIONS_UNIX
+from tests import HAS_MEMORY_FULL_INFO
+from tests import HAS_MEMORY_MAPS
+from tests import HAS_SENSORS_BATTERY
+from tests import HAS_SENSORS_FANS
+from tests import HAS_SENSORS_TEMPERATURES
+from tests import import_module_by_path
+from tests import is_namedtuple
+from tests import mock
+from tests import PYTHON_EXE
+from tests import reap_children
+from tests import reload_module
+from tests import retry
+from tests import ROOT_DIR
+from tests import run_test_module_by_name
+from tests import safe_mkdir
+from tests import safe_rmpath
+from tests import SCRIPTS_DIR
+from tests import sh
+from tests import tcp_socketpair
+from tests import TESTFN
+from tests import TOX
+from tests import TRAVIS
+from tests import unittest
+from tests import unix_socket_path
+from tests import unix_socketpair
+from tests import wait_for_file
+from tests import wait_for_pid
import psutil
-import psutil.tests
+import tests
# ===================================================================
@@ -859,7 +859,7 @@ class TestSyncTestUtils(unittest.TestCase):
def test_wait_for_pid(self):
wait_for_pid(os.getpid())
nopid = max(psutil.pids()) + 99999
- with mock.patch('psutil.tests.retry.__iter__', return_value=iter([0])):
+ with mock.patch('tests.retry.__iter__', return_value=iter([0])):
self.assertRaises(psutil.NoSuchProcess, wait_for_pid, nopid)
def test_wait_for_file(self):
@@ -875,7 +875,7 @@ class TestSyncTestUtils(unittest.TestCase):
assert not os.path.exists(TESTFN)
def test_wait_for_file_no_file(self):
- with mock.patch('psutil.tests.retry.__iter__', return_value=iter([0])):
+ with mock.patch('tests.retry.__iter__', return_value=iter([0])):
self.assertRaises(IOError, wait_for_file, TESTFN)
def test_wait_for_file_no_delete(self):
@@ -914,7 +914,7 @@ class TestFSTestUtils(unittest.TestCase):
safe_rmpath(TESTFN)
assert not os.path.exists(TESTFN)
# test other exceptions are raised
- with mock.patch('psutil.tests.os.stat',
+ with mock.patch('tests.os.stat',
side_effect=OSError(errno.EINVAL, "")) as m:
with self.assertRaises(OSError):
safe_rmpath(TESTFN)
@@ -936,8 +936,8 @@ class TestProcessUtils(unittest.TestCase):
assert p.is_running()
reap_children()
assert not p.is_running()
- assert not psutil.tests._pids_started
- assert not psutil.tests._subprocesses_started
+ assert not tests._pids_started
+ assert not tests._subprocesses_started
def test_create_proc_children_pair(self):
p1, p2 = create_proc_children_pair()
@@ -955,8 +955,8 @@ class TestProcessUtils(unittest.TestCase):
reap_children()
assert not p1.is_running()
assert not p2.is_running()
- assert not psutil.tests._pids_started
- assert not psutil.tests._subprocesses_started
+ assert not tests._pids_started
+ assert not tests._subprocesses_started
@unittest.skipIf(not POSIX, "POSIX only")
def test_create_zombie_proc(self):
diff --git a/psutil/tests/test_osx.py b/tests/test_osx.py
index bcb2ba4e..4e8b2e47 100755
--- a/psutil/tests/test_osx.py
+++ b/tests/test_osx.py
@@ -12,15 +12,15 @@ import time
import psutil
from psutil import OSX
-from psutil.tests import create_zombie_proc
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_BATTERY
-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 unittest
+from tests import create_zombie_proc
+from tests import get_test_subprocess
+from tests import HAS_BATTERY
+from tests import MEMORY_TOLERANCE
+from tests import reap_children
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import sh
+from tests import unittest
PAGESIZE = os.sysconf("SC_PAGE_SIZE") if OSX else None
diff --git a/psutil/tests/test_posix.py b/tests/test_posix.py
index e9a6f5f6..382ebade 100755
--- a/psutil/tests/test_posix.py
+++ b/tests/test_posix.py
@@ -24,20 +24,20 @@ from psutil import OSX
from psutil import POSIX
from psutil import SUNOS
from psutil._compat import PY3
-from psutil.tests import APPVEYOR
-from psutil.tests import get_kernel_version
-from psutil.tests import get_test_subprocess
-from psutil.tests import mock
-from psutil.tests import PYTHON_EXE
-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 TRAVIS
-from psutil.tests import unittest
-from psutil.tests import wait_for_pid
-from psutil.tests import which
+from tests import APPVEYOR
+from tests import get_kernel_version
+from tests import get_test_subprocess
+from tests import mock
+from tests import PYTHON_EXE
+from tests import reap_children
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import sh
+from tests import skip_on_access_denied
+from tests import TRAVIS
+from tests import unittest
+from tests import wait_for_pid
+from tests import which
def ps(cmd):
diff --git a/psutil/tests/test_process.py b/tests/test_process.py
index 33557b05..1c0d6a8c 100755
--- a/psutil/tests/test_process.py
+++ b/tests/test_process.py
@@ -33,40 +33,40 @@ from psutil import SUNOS
from psutil import WINDOWS
from psutil._compat import long
from psutil._compat import PY3
-from psutil.tests import APPVEYOR
-from psutil.tests import call_until
-from psutil.tests import copyload_shared_lib
-from psutil.tests import create_exe
-from psutil.tests import create_proc_children_pair
-from psutil.tests import create_zombie_proc
-from psutil.tests import enum
-from psutil.tests import get_test_subprocess
-from psutil.tests import get_winver
-from psutil.tests import HAS_CPU_AFFINITY
-from psutil.tests import HAS_ENVIRON
-from psutil.tests import HAS_IONICE
-from psutil.tests import HAS_MEMORY_MAPS
-from psutil.tests import HAS_PROC_CPU_NUM
-from psutil.tests import HAS_PROC_IO_COUNTERS
-from psutil.tests import HAS_RLIMIT
-from psutil.tests import HAS_THREADS
-from psutil.tests import mock
-from psutil.tests import PYPY
-from psutil.tests import PYTHON_EXE
-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_rmpath
-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 TESTFILE_PREFIX
-from psutil.tests import TESTFN
-from psutil.tests import ThreadTask
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
-from psutil.tests import wait_for_pid
-from psutil.tests import WIN_VISTA
+from tests import APPVEYOR
+from tests import call_until
+from tests import copyload_shared_lib
+from tests import create_exe
+from tests import create_proc_children_pair
+from tests import create_zombie_proc
+from tests import enum
+from tests import get_test_subprocess
+from tests import get_winver
+from tests import HAS_CPU_AFFINITY
+from tests import HAS_ENVIRON
+from tests import HAS_IONICE
+from tests import HAS_MEMORY_MAPS
+from tests import HAS_PROC_CPU_NUM
+from tests import HAS_PROC_IO_COUNTERS
+from tests import HAS_RLIMIT
+from tests import HAS_THREADS
+from tests import mock
+from tests import PYPY
+from tests import PYTHON_EXE
+from tests import reap_children
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import safe_rmpath
+from tests import sh
+from tests import skip_on_access_denied
+from tests import skip_on_not_implemented
+from tests import TESTFILE_PREFIX
+from tests import TESTFN
+from tests import ThreadTask
+from tests import TRAVIS
+from tests import unittest
+from tests import wait_for_pid
+from tests import WIN_VISTA
# ===================================================================
diff --git a/psutil/tests/test_sunos.py b/tests/test_sunos.py
index ea9afcde..e266fb64 100755
--- a/psutil/tests/test_sunos.py
+++ b/tests/test_sunos.py
@@ -10,9 +10,9 @@ 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 unittest
+from tests import run_test_module_by_name
+from tests import sh
+from tests import unittest
@unittest.skipIf(not SUNOS, "SUNOS only")
diff --git a/psutil/tests/test_system.py b/tests/test_system.py
index 20b132a9..6eb891d4 100755
--- a/psutil/tests/test_system.py
+++ b/tests/test_system.py
@@ -30,26 +30,26 @@ from psutil import POSIX
from psutil import SUNOS
from psutil import WINDOWS
from psutil._compat import long
-from psutil.tests import APPVEYOR
-from psutil.tests import ASCII_FS
-from psutil.tests import check_net_address
-from psutil.tests import DEVNULL
-from psutil.tests import enum
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_BATTERY
-from psutil.tests import HAS_CPU_FREQ
-from psutil.tests import HAS_SENSORS_BATTERY
-from psutil.tests import HAS_SENSORS_FANS
-from psutil.tests import HAS_SENSORS_TEMPERATURES
-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_rmpath
-from psutil.tests import TESTFN
-from psutil.tests import TESTFN_UNICODE
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
+from tests import APPVEYOR
+from tests import ASCII_FS
+from tests import check_net_address
+from tests import DEVNULL
+from tests import enum
+from tests import get_test_subprocess
+from tests import HAS_BATTERY
+from tests import HAS_CPU_FREQ
+from tests import HAS_SENSORS_BATTERY
+from tests import HAS_SENSORS_FANS
+from tests import HAS_SENSORS_TEMPERATURES
+from tests import mock
+from tests import reap_children
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import safe_rmpath
+from tests import TESTFN
+from tests import TESTFN_UNICODE
+from tests import TRAVIS
+from tests import unittest
# ===================================================================
diff --git a/psutil/tests/test_unicode.py b/tests/test_unicode.py
index 6383c9be..ea1a6900 100755
--- a/psutil/tests/test_unicode.py
+++ b/tests/test_unicode.py
@@ -64,28 +64,28 @@ from psutil import POSIX
from psutil import WINDOWS
from psutil._compat import PY3
from psutil._compat import u
-from psutil.tests import APPVEYOR
-from psutil.tests import ASCII_FS
-from psutil.tests import bind_unix_socket
-from psutil.tests import chdir
-from psutil.tests import copyload_shared_lib
-from psutil.tests import create_exe
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_CONNECTIONS_UNIX
-from psutil.tests import HAS_ENVIRON
-from psutil.tests import HAS_MEMORY_MAPS
-from psutil.tests import mock
-from psutil.tests import reap_children
-from psutil.tests import run_test_module_by_name
-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 TESTFILE_PREFIX
-from psutil.tests import TESTFN
-from psutil.tests import TESTFN_UNICODE
-from psutil.tests import TRAVIS
-from psutil.tests import unittest
-from psutil.tests import unix_socket_path
+from tests import APPVEYOR
+from tests import ASCII_FS
+from tests import bind_unix_socket
+from tests import chdir
+from tests import copyload_shared_lib
+from tests import create_exe
+from tests import get_test_subprocess
+from tests import HAS_CONNECTIONS_UNIX
+from tests import HAS_ENVIRON
+from tests import HAS_MEMORY_MAPS
+from tests import mock
+from tests import reap_children
+from tests import run_test_module_by_name
+from tests import safe_mkdir
+from tests import safe_rmpath as _safe_rmpath
+from tests import skip_on_access_denied
+from tests import TESTFILE_PREFIX
+from tests import TESTFN
+from tests import TESTFN_UNICODE
+from tests import TRAVIS
+from tests import unittest
+from tests import unix_socket_path
import psutil
diff --git a/psutil/tests/test_windows.py b/tests/test_windows.py
index 32c46f67..236f2aef 100755
--- a/psutil/tests/test_windows.py
+++ b/tests/test_windows.py
@@ -21,15 +21,15 @@ import warnings
import psutil
from psutil import WINDOWS
-from psutil.tests import APPVEYOR
-from psutil.tests import get_test_subprocess
-from psutil.tests import HAS_BATTERY
-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 sh
-from psutil.tests import unittest
+from tests import APPVEYOR
+from tests import get_test_subprocess
+from tests import HAS_BATTERY
+from tests import mock
+from tests import reap_children
+from tests import retry_before_failing
+from tests import run_test_module_by_name
+from tests import sh
+from tests import unittest
with warnings.catch_warnings():
warnings.simplefilter("ignore")
diff --git a/tox.ini b/tox.ini
index 61d63eee..7ec895af 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,7 +18,7 @@ deps =
setenv =
TOX = 1
-commands = python psutil/tests/__main__.py
+commands = python tests/__main__.py
usedevelop = True