From e82e5fe3c0cb2062865b67ba6fa12753b1daae32 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Thu, 9 Jan 2014 14:14:17 +0100 Subject: [PATCH] Use testr instead of nosetest This patch removes the dependency on nosetest and uses testrepository as a test runner. There are some advantages behind this change: - Better tests execution - Better tests concurrency - Less dependencies Change-Id: I1985bdf03137d32a0774321d8dec5cb015dc9d2f --- .testr.conf | 8 ++++++++ test-requirements.txt | 5 ----- tests/unit/queues/transport/wsgi/test_utils.py | 9 +++++---- tox.ini | 15 ++++++++------- 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 .testr.conf diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 000000000..42a77d387 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t . ./tests $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/test-requirements.txt b/test-requirements.txt index 55edf5d17..dc39a0ad0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -15,8 +15,3 @@ testtools>=0.9.32 # Functional Tests requests>=1.1 - -# Test runner -nose -nose-exclude -openstack.nose_plugin>=0.7 diff --git a/tests/unit/queues/transport/wsgi/test_utils.py b/tests/unit/queues/transport/wsgi/test_utils.py index b6ca74744..b0dd27843 100644 --- a/tests/unit/queues/transport/wsgi/test_utils.py +++ b/tests/unit/queues/transport/wsgi/test_utils.py @@ -18,6 +18,7 @@ import io import json import falcon +import six import testtools from marconi.queues.transport.wsgi import utils @@ -100,7 +101,7 @@ class TestWSGIutils(testtools.TestCase): def test_no_spec(self): obj = {u'body': {'event': 'start_backup'}, 'ttl': 300} - document = json.dumps(obj, ensure_ascii=False) + document = six.text_type(json.dumps(obj, ensure_ascii=False)) doc_stream = io.StringIO(document) filtered = utils.filter_stream(doc_stream, len(document), spec=None) @@ -113,7 +114,7 @@ class TestWSGIutils(testtools.TestCase): def test_no_spec_array(self): things = [{u'body': {'event': 'start_backup'}, 'ttl': 300}] - document = json.dumps(things, ensure_ascii=False) + document = six.text_type(json.dumps(things, ensure_ascii=False)) doc_stream = io.StringIO(document) filtered = utils.filter_stream(doc_stream, len(document), @@ -131,7 +132,7 @@ class TestWSGIutils(testtools.TestCase): def test_filter_stream_expect_obj(self): obj = {u'body': {'event': 'start_backup'}, 'id': 'DEADBEEF'} - document = json.dumps(obj, ensure_ascii=False) + document = six.text_type(json.dumps(obj, ensure_ascii=False)) stream = io.StringIO(document) spec = [('body', dict), ('id', basestring)] filtered_object, = utils.filter_stream(stream, len(document), spec) @@ -146,7 +147,7 @@ class TestWSGIutils(testtools.TestCase): def test_filter_stream_expect_array(self): array = [{u'body': {u'x': 1}}, {u'body': {u'x': 2}}] - document = json.dumps(array, ensure_ascii=False) + document = six.text_type(json.dumps(array, ensure_ascii=False)) stream = io.StringIO(document) spec = [('body', dict)] filtered_objects = list(utils.filter_stream( diff --git a/tox.ini b/tox.ini index e385f5eec..af416dd9b 100644 --- a/tox.ini +++ b/tox.ini @@ -8,15 +8,13 @@ usedevelop = True # Customize pip command, add -U to force updates. install_command = pip install -U {opts} {packages} 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 - NOSE_OPENSTACK_STDOUT=1 + MARCONI_TESTS_DIR={toxinidir}/tests + MARCONI_TESTS_CONFIGS_DIR={toxinidir}/tests/etc/ + deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = nosetests {posargs} +#commands = nosetests {posargs} +commands = python setup.py testr --slowest --testr-args='--concurrency 1 {posargs}' [tox:jenkins] downloadcache = ~/cache/pip @@ -26,6 +24,9 @@ commands = flake8 [testenv:cover] setenv = NOSE_WITH_COVERAGE=1 +commands = + python setup.py testr --coverage \ + --testr-args='^(?!.*test.*coverage).*$' [testenv:venv] commands = {posargs}