Pass statical analisys wiht Python2

Change-Id: I72c4bcf4a4879a104e44633f97293a6f9edbeb43
This commit is contained in:
Federico Ressi
2019-05-24 16:57:54 +02:00
parent 01e64a0af0
commit ef86702f91
15 changed files with 82 additions and 79 deletions

View File

@@ -16,9 +16,10 @@ import shutil
import tempfile
import mock
from oslo_log import log
from tobiko.tests import base
from tobiko.common import _fixture
from tobiko.tests import base
class TobikoUnitTest(base.TobikoTest):
@@ -26,21 +27,21 @@ class TobikoUnitTest(base.TobikoTest):
def setUp(self):
super(TobikoUnitTest, self).setUp()
# Protect from mis-configuring logging
self.patch('oslo_log.log.setup')
self.patch(log, 'setup')
self.fixture_manager = manager = _fixture.FixtureManager()
self.patch_object(_fixture, 'FIXTURES', manager)
self.patch(_fixture, 'FIXTURES', manager)
def patch(self, target, *args, **kwargs):
context = mock.patch(target, *args, **kwargs)
mock_object = context.start()
def patch(self, obj, attribute, value=mock.DEFAULT, spec=None,
create=False, spec_set=None, autospec=None,
new_callable=None, **kwargs):
# pylint: disable=arguments-differ
context = mock.patch.object(target=obj, attribute=attribute, new=value,
spec=spec, create=create,
spec_set=spec_set, autospec=autospec,
new_callable=new_callable, **kwargs)
mocked = context.start()
self.addCleanup(context.stop)
return mock_object
def patch_object(self, target, attribute, *args, **kwargs):
context = mock.patch.object(target, attribute, *args, **kwargs)
mock_object = context.start()
self.addCleanup(context.stop)
return mock_object
return mocked
def create_tempdir(self, *args, **kwargs):
dir_path = tempfile.mkdtemp(*args, **kwargs)