Migrate to testr from nose.

Change-Id: Ibe0c2eeee9aeb4cb1832456cdc0d080a5a9af175
This commit is contained in:
Angus Salkeld 2013-05-31 20:13:37 +10:00
parent 2e6e49f7fa
commit c4174d39ae
6 changed files with 35 additions and 50 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ doc/source/api
heatclient/versioninfo heatclient/versioninfo
python_heatclient.egg-info python_heatclient.egg-info
*.log *.log
.testrepository

4
.testr.conf Normal file
View File

@ -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

View File

@ -6,6 +6,7 @@ import sys
import fixtures import fixtures
import mox import mox
import testscenarios
import testtools import testtools
try: try:
import json import json
@ -18,6 +19,7 @@ from heatclient import exc
import heatclient.shell import heatclient.shell
from heatclient.v1 import client as v1client 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__), TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
'var')) 'var'))
@ -58,42 +60,32 @@ class TestCase(testtools.TestCase):
class EnvVarTest(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): 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 = { fake_env = {
'OS_USERNAME': 'username', 'OS_USERNAME': 'username',
'OS_PASSWORD': None, 'OS_PASSWORD': 'password',
'OS_TENANT_NAME': 'tenant_name', 'OS_TENANT_NAME': 'tenant_name',
'OS_AUTH_URL': 'http://no.where', 'OS_AUTH_URL': 'http://no.where',
} }
fake_env[self.remove] = None
self.set_fake_env(fake_env) self.set_fake_env(fake_env)
self.shell_error('list', 'You must provide a password') self.shell_error('list', self.err)
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')
class ShellValidationTest(TestCase): class ShellValidationTest(TestCase):

View File

@ -29,13 +29,6 @@ console_scripts =
setup-hooks = setup-hooks =
pbr.hooks.setup_hook pbr.hooks.setup_hook
[nosetests]
cover-package = heatclient
cover-html = true
cover-erase = true
cover-inclusive = true
verbosity=2
[build_sphinx] [build_sphinx]
source-dir = doc/source source-dir = doc/source
build-dir = doc/build build-dir = doc/build

View File

@ -6,12 +6,11 @@ pyflakes==0.7.2
flake8==2.0 flake8==2.0
hacking>=0.5.3,<0.6 hacking>=0.5.3,<0.6
coverage>=3.6
discover
fixtures>=0.3.12 fixtures>=0.3.12
mox mox
nose
nose-exclude
nosexcover
openstack.nose_plugin
nosehtmloutput
sphinx>=1.1.2 sphinx>=1.1.2
testscenarios<0.5
testrepository>=0.0.13
testtools>=0.9.29 testtools>=0.9.29

10
tox.ini
View File

@ -3,14 +3,9 @@ envlist = py26,py27,pep8
[testenv] [testenv]
setenv = VIRTUAL_ENV={envdir} 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 deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = nosetests commands = python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8] [testenv:pep8]
commands = flake8 commands = flake8
@ -19,7 +14,8 @@ commands = flake8
commands = {posargs} commands = {posargs}
[testenv:cover] [testenv:cover]
commands = nosetests --cover-erase --cover-package=heatclient --with-xcoverage commands = python setup.py testr --coverage --testr-args='{posargs}'
[tox:jenkins] [tox:jenkins]
downloadcache = ~/cache/pip downloadcache = ~/cache/pip