On Mon, Nov 17, 2014 at 11:29 AM, 'Aaron Karper' via ganeti-devel <[email protected]> wrote: > The config mock is usable not only by cmdlib tests, so this patch moves > it to a place where it's available to all tests. > > Signed-off-by: Aaron Karper <[email protected]> > --- > test/py/cmdlib/testsupport/__init__.py | 2 +- > test/py/cmdlib/testsupport/cmdlib_testcase.py | 2 +- > test/py/ganeti.config_unittest.py | 2 +- > test/py/{testutils.py => testutils/__init__.py} | 14 ++++++++++++++ > test/py/{cmdlib/testsupport => testutils}/config_mock.py | 0 > 5 files changed, 17 insertions(+), 3 deletions(-) > rename test/py/{testutils.py => testutils/__init__.py} (96%) > rename test/py/{cmdlib/testsupport => testutils}/config_mock.py (100%) > > diff --git a/test/py/cmdlib/testsupport/__init__.py > b/test/py/cmdlib/testsupport/__init__.py > index e25fc27..4d4b6b9 100644 > --- a/test/py/cmdlib/testsupport/__init__.py > +++ b/test/py/cmdlib/testsupport/__init__.py > @@ -34,7 +34,7 @@ > > from cmdlib.testsupport.cmdlib_testcase import CmdlibTestCase, \ > withLockedLU > -from cmdlib.testsupport.config_mock import ConfigMock > +from testutils.config_mock import ConfigMock > from cmdlib.testsupport.iallocator_mock import patchIAllocator > from cmdlib.testsupport.livelock_mock import LiveLockMock > from cmdlib.testsupport.utils_mock import patchUtils > diff --git a/test/py/cmdlib/testsupport/cmdlib_testcase.py > b/test/py/cmdlib/testsupport/cmdlib_testcase.py > index 09a6917..76b57d1 100644 > --- a/test/py/cmdlib/testsupport/cmdlib_testcase.py > +++ b/test/py/cmdlib/testsupport/cmdlib_testcase.py > @@ -38,7 +38,7 @@ import traceback > import functools > import sys > > -from cmdlib.testsupport.config_mock import ConfigMock > +from testutils.config_mock import ConfigMock > from cmdlib.testsupport.iallocator_mock import patchIAllocator > from cmdlib.testsupport.livelock_mock import LiveLockMock > from cmdlib.testsupport.netutils_mock import patchNetutils, \ > diff --git a/test/py/ganeti.config_unittest.py > b/test/py/ganeti.config_unittest.py > index efcf9cb..b9726c2 100755 > --- a/test/py/ganeti.config_unittest.py > +++ b/test/py/ganeti.config_unittest.py > @@ -51,7 +51,7 @@ from ganeti.config import TemporaryReservationManager > import testutils > import mocks > import mock > -from cmdlib.testsupport.config_mock import ConfigMock > +from testutils.config_mock import ConfigMock > > > def _StubGetEntResolver(): > diff --git a/test/py/testutils.py b/test/py/testutils/__init__.py > similarity index 96% > rename from test/py/testutils.py > rename to test/py/testutils/__init__.py > index fe425aa..27ca425 100644 > --- a/test/py/testutils.py > +++ b/test/py/testutils/__init__.py > @@ -124,6 +124,14 @@ class GanetiTestCase(unittest.TestCase): > """ > def setUp(self): > self._temp_files = [] > + self.patches = {} > + self.mocks = {} > + > + def MockOut(self, name, patch=None): > + if patch is None: > + patch = name > + self.patches[name] = patch > + self.mocks[name] = patch.start() > > def tearDown(self): > while self._temp_files: > @@ -132,6 +140,12 @@ class GanetiTestCase(unittest.TestCase): > except EnvironmentError: > pass > > + for patch in self.patches.values(): > + patch.stop() > + > + self.patches = {} > + self.mocks = {} > + > def assertFileContent(self, file_name, expected_content): > """Checks that the content of a file is what we expect. > > diff --git a/test/py/cmdlib/testsupport/config_mock.py > b/test/py/testutils/config_mock.py > similarity index 100% > rename from test/py/cmdlib/testsupport/config_mock.py > rename to test/py/testutils/config_mock.py > -- > 2.1.0.rc2.206.gedb03e5 >
LGTM, thanks. Michele -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
