Allow mock-based patching in shell tests

Added `patch` method that uses mock.patch (similar to `patchobject`)
  - NOTE: this shadows `testtools.TestCase.patch` method that uses
    simple monkey-patching in favor of mock-based patching,
    relevant comment added in the code.
Also oslotest dependency is added.

Change-Id: Ie4d25bc53decb308398eded350c81a90a257b254
Related-Bug: #1384511
This commit is contained in:
Tetyana Lashchova 2014-10-27 15:32:01 +02:00
parent 49d000c295
commit 0cdb56139f
2 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import fixtures
import httpretty
from keystoneclient.fixture import v2 as ks_v2_fixture
from keystoneclient.fixture import v3 as ks_v3_fixture
from oslotest import mockpatch
import requests
import tempfile
import testscenarios
@ -132,6 +133,12 @@ class TestCase(testtools.TestCase):
keystone_client_fixtures.BASE_URL,
body=keystone_client_fixtures.keystone_request_callback)
# NOTE(tlashchova): this overrides the testtools.TestCase.patch method
# that does simple monkey-patching in favor of mock's patching
def patch(self, target, **kwargs):
mockfixture = self.useFixture(mockpatch.Patch(target, **kwargs))
return mockfixture.mock
class EnvVarTest(TestCase):

View File

@ -11,6 +11,7 @@ httpretty>=0.8.0,!=0.8.1,!=0.8.2,!=0.8.3
mock>=1.0
mox3>=0.7.0
oslosphinx>=2.2.0 # Apache-2.0
oslotest>=1.2.0 # Apache-2.0
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
testrepository>=0.0.18
testscenarios>=0.4