Add mox fixture to base TestCase
Change-Id: I30b62ba153914cda23bb24683dea7c6441b7ef99
This commit is contained in:
parent
b31563ed18
commit
28af5524bd
@ -12,11 +12,29 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import fixtures
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import fixtures
|
||||||
|
import mox
|
||||||
|
import stubout
|
||||||
import testtools
|
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):
|
class TestCase(testtools.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -29,3 +47,7 @@ class TestCase(testtools.TestCase):
|
|||||||
os.environ.get('OS_STDERR_CAPTURE') == '1'):
|
os.environ.get('OS_STDERR_CAPTURE') == '1'):
|
||||||
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
||||||
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
||||||
|
|
||||||
|
mox_fixture = self.useFixture(MoxStubout())
|
||||||
|
self.mox = mox_fixture.mox
|
||||||
|
self.stubs = mox_fixture.stubs
|
||||||
|
@ -8,4 +8,5 @@ sphinx>=1.1.2
|
|||||||
oslo.sphinx
|
oslo.sphinx
|
||||||
testrepository>=0.0.17
|
testrepository>=0.0.17
|
||||||
testscenarios>=0.4,<0.5
|
testscenarios>=0.4,<0.5
|
||||||
testtools>=0.9.32
|
testtools>=0.9.32
|
||||||
|
mox>=0.5.3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user