From 89900171a89f5a3cfbeaa6c4dd139610430371d1 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Mon, 3 Mar 2014 20:45:02 -0500 Subject: [PATCH] Start using oslotest for tempest unit tests This commit starts using the oslotest library. The fixture oslo-incubator library is still left in the tree because I didn't see the Config fixture in the library tree yet. Also, it's probably worth noting that if the lock fixture is moved from incubator to the library that oslotest will become a runtime requirement on tempest. (which probably means we'll want to install it from git in the gate) Change-Id: I638f28975dff4cde2e4eaa6c154a41e66a0746e4 --- tempest/tests/base.py | 18 +++--------------- tempest/tests/test_auth.py | 3 ++- tempest/tests/test_decorators.py | 5 ++--- tempest/tests/test_rest_client.py | 3 ++- test-requirements.txt | 1 + 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/tempest/tests/base.py b/tempest/tests/base.py index 15e4311058..f4df3b90eb 100644 --- a/tempest/tests/base.py +++ b/tempest/tests/base.py @@ -12,28 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. -import os - -import fixtures import mock -import testtools -from tempest.openstack.common.fixture import moxstubout +from oslotest import base +from oslotest import moxstubout -class TestCase(testtools.TestCase): +class TestCase(base.BaseTestCase): def setUp(self): super(TestCase, self).setUp() - if (os.environ.get('OS_STDOUT_CAPTURE') == 'True' or - os.environ.get('OS_STDOUT_CAPTURE') == '1'): - stdout = self.useFixture(fixtures.StringStream('stdout')).stream - self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) - if (os.environ.get('OS_STDERR_CAPTURE') == 'True' or - os.environ.get('OS_STDERR_CAPTURE') == '1'): - stderr = self.useFixture(fixtures.StringStream('stderr')).stream - self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) - mox_fixture = self.useFixture(moxstubout.MoxStubout()) self.mox = mox_fixture.mox self.stubs = mox_fixture.stubs diff --git a/tempest/tests/test_auth.py b/tempest/tests/test_auth.py index 03333bef1b..1dcddad87b 100644 --- a/tempest/tests/test_auth.py +++ b/tempest/tests/test_auth.py @@ -16,11 +16,12 @@ import copy import datetime +from oslotest import mockpatch + from tempest import auth from tempest.common import http from tempest import config from tempest import exceptions -from tempest.openstack.common.fixture import mockpatch from tempest.tests import base from tempest.tests import fake_auth_provider from tempest.tests import fake_config diff --git a/tempest/tests/test_decorators.py b/tempest/tests/test_decorators.py index 804204a35d..6b678f790a 100644 --- a/tempest/tests/test_decorators.py +++ b/tempest/tests/test_decorators.py @@ -14,13 +14,12 @@ import mock -import testtools - from oslo.config import cfg +from oslotest import mockpatch +import testtools from tempest import config from tempest import exceptions -from tempest.openstack.common.fixture import mockpatch from tempest import test from tempest.tests import base from tempest.tests import fake_config diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py index 64ad3bcf98..d20520cf66 100644 --- a/tempest/tests/test_rest_client.py +++ b/tempest/tests/test_rest_client.py @@ -15,11 +15,12 @@ import httplib2 import json +from oslotest import mockpatch + from tempest.common import rest_client from tempest.common import xml_utils as xml from tempest import config from tempest import exceptions -from tempest.openstack.common.fixture import mockpatch from tempest.tests import base from tempest.tests import fake_auth_provider from tempest.tests import fake_config diff --git a/test-requirements.txt b/test-requirements.txt index 8d64167722..46a45df49a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,3 +7,4 @@ oslosphinx mox>=0.5.3 mock>=1.0 coverage>=3.6 +oslotest