Skip to content

Commit

Permalink
Merge c0c27d1 into f4cce68
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Apr 25, 2020
2 parents f4cce68 + c0c27d1 commit 72af351
Show file tree
Hide file tree
Showing 22 changed files with 300 additions and 126 deletions.
10 changes: 2 additions & 8 deletions .ci/travis/install.sh
Expand Up @@ -16,10 +16,6 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
fi

case "${PYVER}" in
# py26)
# pyenv install 2.6.9
# pyenv virtualenv 2.6.9 psutil
# ;;
py27)
pyenv install 2.7.16
pyenv virtualenv 2.7.16 psutil
Expand All @@ -33,10 +29,8 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
pyenv activate psutil
fi

if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]] || [[ $PYVER == 'py26' ]]; then
pip install -U ipaddress unittest2 argparse mock==1.0.1
elif [[ $TRAVIS_PYTHON_VERSION == '2.7' ]] || [[ $PYVER == 'py27' ]]; then
if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]] || [[ $PYVER == 'py27' ]]; then
pip install -U ipaddress mock
fi

pip install -U coverage coveralls flake8 setuptools
pip install -U coverage coveralls flake8 setuptools concurrencytest
2 changes: 1 addition & 1 deletion .ci/travis/run.sh
Expand Up @@ -22,7 +22,7 @@ python setup.py develop
if [[ $PYVER == '2.7' ]] && [[ "$(uname -s)" != 'Darwin' ]]; then
PSUTIL_TESTING=1 python -Wa -m coverage run psutil/tests/runner.py
else
PSUTIL_TESTING=1 python -Wa psutil/tests/runner.py
PSUTIL_TESTING=1 python -Wa psutil/tests/runner.py --parallel
fi

if [ "$PYVER" == "2.7" ] || [ "$PYVER" == "3.6" ]; then
Expand Down
8 changes: 4 additions & 4 deletions .cirrus.yml
Expand Up @@ -6,10 +6,10 @@ freebsd_13_py3_task:
install_script:
- pkg install -y python3 gcc py37-pip
script:
- python3 -m pip install --user setuptools
- python3 -m pip install --user setuptools concurrencytest
- make clean
- make install
- make test
- make test-parallel
- make test-memleaks
- make print-access-denied
- make print-api-speed
Expand All @@ -22,10 +22,10 @@ freebsd_11_py2_task:
install_script:
- pkg install -y python gcc py27-pip
script:
- python2.7 -m pip install --user setuptools ipaddress mock
- python2.7 -m pip install --user setuptools ipaddress mock concurrencytest
- make clean
- make install
- make test
- make test-parallel
- make test-memleaks
- make print-access-denied
- make print-api-speed
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,6 @@ matrix:
env: PYVER=py36
# Linux
- python: 2.7
- python: 3.4
- python: 3.5
- python: 3.6
- python: 3.7
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Expand Up @@ -9,6 +9,7 @@ ARGS =
DEPS = \
argparse \
check-manifest \
concurrencytest \
coverage \
flake8 \
flake8-print \
Expand Down Expand Up @@ -112,6 +113,10 @@ test: ## Run all tests.
${MAKE} install
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT)

test-parallel: ## Run all tests in parallel.
${MAKE} install
$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) --parallel

test-process: ## Run process-related API tests.
${MAKE} install
$(TEST_PREFIX) $(PYTHON) psutil/tests/test_process.py
Expand Down Expand Up @@ -154,7 +159,7 @@ test-memleaks: ## Memory leak tests.

test-by-name: ## e.g. make test-by-name ARGS=psutil.tests.test_system.TestSystemAPIs
${MAKE} install
@$(TEST_PREFIX) $(PYTHON) -m unittest -v $(ARGS)
@$(TEST_PREFIX) $(PYTHON) $(TSCRIPT) $(ARGS)

test-failed: ## Re-run tests which failed on last run
${MAKE} install
Expand Down
16 changes: 13 additions & 3 deletions psutil/tests/__init__.py
Expand Up @@ -15,6 +15,7 @@
import errno
import functools
import gc
import inspect
import os
import random
import re
Expand Down Expand Up @@ -799,8 +800,17 @@ def __str__(self):


# monkey patch default unittest.TestCase
if 'PSUTIL_TESTING' in os.environ:
unittest.TestCase = TestCase
unittest.TestCase = TestCase


def serialrun(klass):
"""A decorator to mark a TestCase class. When running parallel tests,
class' unit tests will be run serially (1 process).
"""
# assert issubclass(klass, unittest.TestCase), klass
assert inspect.isclass(klass), klass
klass._serialrun = True
return klass


@unittest.skipIf(PYPY, "unreliable on PYPY")
Expand Down Expand Up @@ -1249,5 +1259,5 @@ def cleanup_test_procs():
# modul. With this it will. See:
# http://grodola.blogspot.com/
# 2016/02/how-to-always-execute-exit-functions-in-py.html
if POSIX and 'PSUTIL_TESTING' in os.environ:
if POSIX:
signal.signal(signal.SIGTERM, lambda sig, frame: sys.exit(sig))

0 comments on commit 72af351

Please sign in to comment.