Add mox fixture to base TestCase

Change-Id: I30b62ba153914cda23bb24683dea7c6441b7ef99
This commit is contained in:
Matthew Treinish 2013-10-01 16:16:28 -04:00
parent b31563ed18
commit 28af5524bd
2 changed files with 25 additions and 2 deletions

View File

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

View File

@ -8,4 +8,5 @@ sphinx>=1.1.2
oslo.sphinx
testrepository>=0.0.17
testscenarios>=0.4,<0.5
testtools>=0.9.32
testtools>=0.9.32
mox>=0.5.3