From 5185af8fb6906d0c1f1361e36c96ac3999c96c65 Mon Sep 17 00:00:00 2001 From: Andriy Popovych Date: Fri, 3 Jul 2015 10:30:05 +0300 Subject: [PATCH] Replace nosetests with pytest Now we use pytests in fuel-web and nosetests in python-fuelclient, so it's better to choose one of them and pytest more preferable choice. Same framework for stackforge python projects gives us more unified ecosystem for testing and also it's easier to support only one. Closes-Bug: #1471815 Change-Id: I786bc966572a3e022592a40a3b61596a6c264e54 --- fuelclient/tests/v1/unit/test_performance.py | 10 ++++------ run_tests.sh | 7 +++---- test-requirements.txt | 6 +++--- tox.ini | 5 +++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/fuelclient/tests/v1/unit/test_performance.py b/fuelclient/tests/v1/unit/test_performance.py index 799418c..8f6986c 100644 --- a/fuelclient/tests/v1/unit/test_performance.py +++ b/fuelclient/tests/v1/unit/test_performance.py @@ -21,7 +21,7 @@ import tarfile import time import mock -import nose +import pytest import requests from six import moves as six_moves @@ -33,6 +33,9 @@ from fuelclient.tests import base from fuelclient.tests import utils +@pytest.mark.skipif(not profiler.profiling_enabled(), + reason='Performance profiling tests are not ' + 'enabled in settings.yaml') class ClientPerfTest(base.UnitTestCase): NUMBER_OF_NODES = 100 @@ -40,11 +43,6 @@ class ClientPerfTest(base.UnitTestCase): @classmethod def setUpClass(cls): super(ClientPerfTest, cls).setUpClass() - - if not profiler.profiling_enabled(): - raise nose.SkipTest('Performance profiling tests are not ' - 'enabled in settings.yaml') - cls.nodes = cls.get_random_nodes(cls.NUMBER_OF_NODES) settings = fuelclient_settings.get_settings() test_base = settings.PERF_TESTS_PATHS['perf_tests_base'] diff --git a/run_tests.sh b/run_tests.sh index 8e826a8..a7c13dd 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -31,10 +31,9 @@ NAILGUN_CHECK_URL=${NAILGUN_CHECK_URL:-"http://0.0.0.0:$NAILGUN_PORT/api/version NAILGUN_START_MAX_WAIT_TIME=${NAILGUN_START_MAX_WAIT_TIME:-10} TEST_NAILGUN_DB=${TEST_NAILGUN_DB:-nailgun} -# nosetest xunit options +# pytest options ARTIFACTS=${ARTIFACTS:-$(pwd)/test_run} -FUELCLIENT_XUNIT=${FUELCLIENT_XUNIT:-"$ROOT/fuelclient.xml"} -TEST_WORKERS=${TEST_WORKERS:-0} +FUELCLIENT_JUNIT=${FUELCLIENT_JUNIT:-"$ROOT/fuelclient.xml"} # A POSIX variable OPTIND=1 @@ -195,7 +194,7 @@ run_cli_tests() { # run tests NAILGUN_CONFIG=$config LISTEN_PORT=$NAILGUN_PORT \ NAILGUN_ROOT=$NAILGUN_ROOT tox -e$env_to_run -- -vv $testropts \ - ${certain_tests[@]} --xunit-file $FUELCLIENT_XUNIT || return 1 + ${certain_tests[@]} --junit-xml $FUELCLIENT_JUNIT || return 1 popd > /dev/null return 0 diff --git a/test-requirements.txt b/test-requirements.txt index af117c8..2304f30 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,8 @@ hacking==0.7 mock==1.0.1 -nose<=1.3.1 -nose2==0.4.1 -nose-timer==0.2.0 +unittest2==0.5.1 pyprof2calltree==1.3.2 gprof2dot==2014.09.29 requests-mock>=0.6.0 +pytest==2.7.2 +pytest-cov==2.0.0 diff --git a/tox.ini b/tox.ini index 7dd3295..fca2aa6 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = - nosetests {posargs:fuelclient} + py.test {posargs:fuelclient} [tox:jenkins] downloadcache = ~/cache/pip @@ -22,7 +22,8 @@ commands = flake8 {posargs:fuelclient} [testenv:cover] -setenv = NOSE_WITH_COVERAGE=1 +commands = + py.test --cov={posargs:fuelclient} tests/ [testenv:venv] commands = {posargs:}