diff --git a/.gitignore b/.gitignore index 1740af6d..a50acc9c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,9 @@ ChangeLog *.log .tox .coverage -oslo_config.egg-info/ +oslo.config.egg-info/ build/ doc/build/ doc/source/api/ dist/ +.testrepository/ diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..1641f86e --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/tests/utils.py b/tests/utils.py index 625e7d44..e0b8d653 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -20,11 +20,15 @@ """Common utilities used in testing""" +import os + import fixtures import mox import stubout import testtools +TRUE_VALUES = ('true', '1', 'yes') + class MoxStubout(fixtures.Fixture): """Deal with code around mox and stubout as a fixture.""" @@ -47,4 +51,20 @@ class BaseTestCase(testtools.TestCase): super(BaseTestCase, self).setUp() self.stubs = self.useFixture(MoxStubout()).stubs self.useFixture(fixtures.FakeLogger('oslo.config')) - self.useFixture(fixtures.Timeout(30, True)) + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 30) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid, fail hard. + print("OS_TEST_TIMEOUT set to invalid value" + " defaulting to no timeout") + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + + if os.environ.get('OS_STDOUT_CAPTURE') in TRUE_VALUES: + stdout = self.useFixture(fixtures.StringStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in TRUE_VALUES: + stderr = self.useFixture(fixtures.StringStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) diff --git a/tools/test-requires b/tools/test-requires index 9d45c3b0..c020cbc2 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -1,8 +1,9 @@ +discover fixtures>=0.3.12 mox -nose -nose-exclude -testtools>=0.9.22 +python-subunit +testrepository>=0.0.13 +testtools>=0.9.29 # when we can require tox>= 1.4, this can go into tox.ini: # [testenv:cover] diff --git a/tox.ini b/tox.ini index 751bd8f9..74c6792f 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = py26,py27,pep8,pylint setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/tools/pip-requires -r{toxinidir}/tools/test-requires -commands = nosetests --with-doctest --exclude-dir=tests/testmods {posargs} +commands = python setup.py testr --slowest --testr-args='{posargs}' [testenv:pep8] deps = pep8==1.3.3 @@ -17,7 +17,10 @@ commands = python ./tools/lint.py ./oslo python ./tools/lint.py ./tests [testenv:cover] -setenv = NOSE_WITH_COVERAGE=1 +setenv = VIRTUAL_ENV={envdir} +commands = + python setup.py testr --coverage + [testenv:venv] commands = {posargs}