From 28af5524bd94978c20d6d05d8fae6cd89f660038 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 1 Oct 2013 16:16:28 -0400 Subject: [PATCH] Add mox fixture to base TestCase Change-Id: I30b62ba153914cda23bb24683dea7c6441b7ef99 --- elastic_recheck/tests/__init__.py | 24 +++++++++++++++++++++++- test-requirements.txt | 3 ++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/elastic_recheck/tests/__init__.py b/elastic_recheck/tests/__init__.py index a18f4142..4c141af8 100644 --- a/elastic_recheck/tests/__init__.py +++ b/elastic_recheck/tests/__init__.py @@ -12,11 +12,29 @@ # License for the specific language governing permissions and limitations # under the License. -import fixtures import os + +import fixtures +import mox +import stubout import testtools +class MoxStubout(fixtures.Fixture): + """Deal with code around mox and stubout as a fixture.""" + + def setUp(self): + super(MoxStubout, self).setUp() + # emulate some of the mox stuff, we can't use the metaclass + # because it screws with our generators + self.mox = mox.Mox() + self.stubs = stubout.StubOutForTesting() + self.addCleanup(self.stubs.UnsetAll) + self.addCleanup(self.stubs.SmartUnsetAll) + self.addCleanup(self.mox.UnsetStubs) + self.addCleanup(self.mox.VerifyAll) + + class TestCase(testtools.TestCase): def setUp(self): @@ -29,3 +47,7 @@ class TestCase(testtools.TestCase): 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()) + self.mox = mox_fixture.mox + self.stubs = mox_fixture.stubs diff --git a/test-requirements.txt b/test-requirements.txt index 3434db12..0ff44dec 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,4 +8,5 @@ sphinx>=1.1.2 oslo.sphinx testrepository>=0.0.17 testscenarios>=0.4,<0.5 -testtools>=0.9.32 \ No newline at end of file +testtools>=0.9.32 +mox>=0.5.3