Nir Soffer has uploaded a new change for review.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
tests: Fix patchDecorators so decorated function will actually run
Commit 5c5a0d9c5 introduced a fancy decorator for cleaning up the mess when we monkey patch conifguratiors. Unfortunatly, this decorator has an unexpected side effect, of *not* running the decorated function, so the test would always pass, even if the code is broken.
This patch replaces this decorator with a much simpler one that let the real decorator (MonkeyPatch) do the right thing.
Change-Id: I1c4be2a15160be48b56a7df2f406e4e0afabd11e Signed-off-by: Nir Soffer nsoffer@redhat.com --- M tests/toolTests.py 1 file changed, 22 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/34153/1
diff --git a/tests/toolTests.py b/tests/toolTests.py index ee0f750..daba9fe 100644 --- a/tests/toolTests.py +++ b/tests/toolTests.py @@ -34,7 +34,6 @@ from testlib import VdsmTestCase from testValidation import ValidateRunningAsRoot from unittest import TestCase -import functools import tempfile import os import shutil @@ -78,15 +77,28 @@
def patchConfigurators(mockConfigurers): - def decorator(f): - @functools.wraps(f) - def wrapper(*args, **kw): - monkeypatch.MonkeyPatch( - configurator, - '_CONFIGURATORS', - dict((m.name, m) for m in mockConfigurers)) - return wrapper - return decorator + return monkeypatch.MonkeyPatch( + configurator, + '_CONFIGURATORS', + dict((m.name, m) for m in mockConfigurers)) + + +class PatchConfiguratorsTests(VdsmTestCase): + + def testPatch(self): + self.configurator = MockModuleConfigurator('a') + self.function_was_run = False + + @patchConfigurators((self.configurator,)) + def function(): + self.function_was_run = True + conf = configurator._CONFIGURATORS[self.configurator.name] + self.assertTrue(conf is self.configurator) + + self.assertFalse(self.configurator.name in configurator._CONFIGURATORS) + function() + self.assertTrue(self.function_was_run) + self.assertFalse(self.configurator.name in configurator._CONFIGURATORS)
class ConfiguratorTests(VdsmTestCase):
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/12960/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/12802/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/12011/ : FAILURE
Nir Soffer has posted comments on this change.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
Patch Set 1: Verified+1
mooli tayer has posted comments on this change.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
Patch Set 1: Code-Review+1
Nir Soffer has posted comments on this change.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
Patch Set 1:
We need this for 3.5, otherwise we may miss test failures.
Dan Kenigsberg has posted comments on this change.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
Patch Set 1: Code-Review+2
5c5a0d9c5 was never meant to reach 3.5. Please keep it (and this fix) out of the stable branch.
Dan Kenigsberg has submitted this change and it was merged.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
tests: Fix patchDecorators so decorated function will actually run
Commit 5c5a0d9c5 introduced a fancy decorator for cleaning up the mess when we monkey patch conifguratiors. Unfortunatly, this decorator has an unexpected side effect, of *not* running the decorated function, so the test would always pass, even if the code is broken.
This patch replaces this decorator with a much simpler one that let the real decorator (MonkeyPatch) do the right thing.
Change-Id: I1c4be2a15160be48b56a7df2f406e4e0afabd11e Signed-off-by: Nir Soffer nsoffer@redhat.com Reviewed-on: http://gerrit.ovirt.org/34153 Reviewed-by: mooli tayer mtayer@redhat.com Reviewed-by: Dan Kenigsberg danken@redhat.com --- M tests/toolTests.py 1 file changed, 22 insertions(+), 10 deletions(-)
Approvals: Nir Soffer: Verified mooli tayer: Looks good to me, but someone else must approve Dan Kenigsberg: Looks good to me, approved
oVirt Jenkins CI Server has posted comments on this change.
Change subject: tests: Fix patchDecorators so decorated function will actually run ......................................................................
Patch Set 2:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_merged/4080/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_create-rpms-fc21-x86_64_merged/66/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_create-rpms-el6-x86_64_merged/94/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_create-rpms_merged_test_debug/288/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_verify-error-codes_merged/5920/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_create-rpms-el7-x86_64_merged/91/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_create-rpms-fc20-x86_64_merged/86/ : SUCCESS
vdsm-patches@lists.fedorahosted.org