From c4174d39ae460f3064ca7cfb1cb20ba9bd2d3e14 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 31 May 2013 20:13:37 +1000 Subject: [PATCH] Migrate to testr from nose. Change-Id: Ibe0c2eeee9aeb4cb1832456cdc0d080a5a9af175 --- .gitignore | 1 + .testr.conf | 4 +++ heatclient/tests/test_shell.py | 54 +++++++++++++++------------------- setup.cfg | 7 ----- test-requirements.txt | 9 +++--- tox.ini | 10 ++----- 6 files changed, 35 insertions(+), 50 deletions(-) create mode 100644 .testr.conf diff --git a/.gitignore b/.gitignore index 95a93141..207ad4e5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ doc/source/api heatclient/versioninfo python_heatclient.egg-info *.log +.testrepository diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..a2ff14b2 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py index e925a3f7..6e874e27 100644 --- a/heatclient/tests/test_shell.py +++ b/heatclient/tests/test_shell.py @@ -6,6 +6,7 @@ import sys import fixtures import mox +import testscenarios import testtools try: import json @@ -18,6 +19,7 @@ from heatclient import exc import heatclient.shell from heatclient.v1 import client as v1client +load_tests = testscenarios.load_tests_apply_scenarios TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'var')) @@ -58,42 +60,32 @@ class TestCase(testtools.TestCase): class EnvVarTest(TestCase): + scenarios = [ + ('username', dict( + remove='OS_USERNAME', + err='You must provide a username')), + ('password', dict( + remove='OS_PASSWORD', + err='You must provide a password')), + ('tenant_name', dict( + remove='OS_TENANT_NAME', + err='You must provide a tenant_id')), + ('auth_url', dict( + remove='OS_AUTH_URL', + err='You must provide an auth url')), + ] + def test_missing_auth(self): - fake_env = { - 'OS_USERNAME': None, - 'OS_PASSWORD': 'password', - 'OS_TENANT_NAME': 'tenant_name', - 'OS_AUTH_URL': 'http://no.where', - } - self.set_fake_env(fake_env) - self.shell_error('list', 'You must provide a username') fake_env = { - 'OS_USERNAME': 'username', - 'OS_PASSWORD': None, - 'OS_TENANT_NAME': 'tenant_name', - 'OS_AUTH_URL': 'http://no.where', + 'OS_USERNAME': 'username', + 'OS_PASSWORD': 'password', + 'OS_TENANT_NAME': 'tenant_name', + 'OS_AUTH_URL': 'http://no.where', } + fake_env[self.remove] = None self.set_fake_env(fake_env) - self.shell_error('list', 'You must provide a password') - - fake_env = { - 'OS_USERNAME': 'username', - 'OS_PASSWORD': 'password', - 'OS_TENANT_NAME': None, - 'OS_AUTH_URL': 'http://no.where', - } - self.set_fake_env(fake_env) - self.shell_error('list', 'You must provide a tenant_id') - - fake_env = { - 'OS_USERNAME': 'username', - 'OS_PASSWORD': 'password', - 'OS_TENANT_NAME': 'tenant_name', - 'OS_AUTH_URL': None, - } - self.set_fake_env(fake_env) - self.shell_error('list', 'You must provide an auth url') + self.shell_error('list', self.err) class ShellValidationTest(TestCase): diff --git a/setup.cfg b/setup.cfg index 50c953db..66c8d40a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,13 +29,6 @@ console_scripts = setup-hooks = pbr.hooks.setup_hook -[nosetests] -cover-package = heatclient -cover-html = true -cover-erase = true -cover-inclusive = true -verbosity=2 - [build_sphinx] source-dir = doc/source build-dir = doc/build diff --git a/test-requirements.txt b/test-requirements.txt index ce667727..51a881be 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,12 +6,11 @@ pyflakes==0.7.2 flake8==2.0 hacking>=0.5.3,<0.6 +coverage>=3.6 +discover fixtures>=0.3.12 mox -nose -nose-exclude -nosexcover -openstack.nose_plugin -nosehtmloutput sphinx>=1.1.2 +testscenarios<0.5 +testrepository>=0.0.13 testtools>=0.9.29 diff --git a/tox.ini b/tox.ini index 91a05954..917dcc75 100644 --- a/tox.ini +++ b/tox.ini @@ -3,14 +3,9 @@ envlist = py26,py27,pep8 [testenv] setenv = VIRTUAL_ENV={envdir} - NOSE_WITH_OPENSTACK=1 - NOSE_OPENSTACK_COLOR=1 - NOSE_OPENSTACK_RED=0.05 - NOSE_OPENSTACK_YELLOW=0.025 - NOSE_OPENSTACK_SHOW_ELAPSED=1 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = nosetests +commands = python setup.py testr --slowest --testr-args='{posargs}' [testenv:pep8] commands = flake8 @@ -19,7 +14,8 @@ commands = flake8 commands = {posargs} [testenv:cover] -commands = nosetests --cover-erase --cover-package=heatclient --with-xcoverage +commands = python setup.py testr --coverage --testr-args='{posargs}' + [tox:jenkins] downloadcache = ~/cache/pip