Nir Soffer has uploaded a new change for review. Change subject: tests: Use frozenset instead of set ......................................................................
tests: Use frozenset instead of set Using frozenset ensure that bad code trying ot motate the return value of requires() will fail. Instead of replacing all set(...) calls with frozenset(...), I'm creating the frozenset in __init__, so there is no way to create an instance with the wrong type. This also cleans up code that creates a mock configurator without any dependencies. Change-Id: I11835fe49ffcc3e4cbfdbc4272bc31429b6be2e1 Signed-off-by: Nir Soffer <nsof...@redhat.com> --- M tests/toolTests.py 1 file changed, 21 insertions(+), 21 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/86/31786/1 diff --git a/tests/toolTests.py b/tests/toolTests.py index e034ad0..995b87a 100644 --- a/tests/toolTests.py +++ b/tests/toolTests.py @@ -38,9 +38,9 @@ class MockModuleConfigurator(ModuleConfigure): - def __init__(self, name, dependencies): + def __init__(self, name, dependencies=()): self._name = name - self._dependencies = dependencies + self._dependencies = frozenset(dependencies) def __repr__(self): return "name: %s, dependencies: %s" % (self._name, self._dependencies) @@ -58,8 +58,8 @@ configurator, '_getConfigurers', lambda: { - 'a': MockModuleConfigurator('a', set(['b'])), - 'b': MockModuleConfigurator('b', set(['a'])) + 'a': MockModuleConfigurator('a', ['b']), + 'b': MockModuleConfigurator('b', ['a']) } ) def testDependencyCircle(self): @@ -73,12 +73,12 @@ configurator, '_getConfigurers', lambda: { - 'a': MockModuleConfigurator('a', set(['b', 'd'])), - 'b': MockModuleConfigurator('b', set(['c'])), - 'c': MockModuleConfigurator('c', set(['e', 'd'])), - 'd': MockModuleConfigurator('d', set(['e', 'e'])), - 'e': MockModuleConfigurator('e', set()), - 'f': MockModuleConfigurator('f', set()), + 'a': MockModuleConfigurator('a', ['b', 'd']), + 'b': MockModuleConfigurator('b', ['c']), + 'c': MockModuleConfigurator('c', ['e', 'd']), + 'd': MockModuleConfigurator('d', ['e', 'e']), + 'e': MockModuleConfigurator('e'), + 'f': MockModuleConfigurator('f'), } ) @@ -95,9 +95,9 @@ configurator, '_getConfigurers', lambda: { - 'a': MockModuleConfigurator('a', set()), - 'b': MockModuleConfigurator('b', set()), - 'c': MockModuleConfigurator('c', set()) + 'a': MockModuleConfigurator('a'), + 'b': MockModuleConfigurator('b'), + 'c': MockModuleConfigurator('c') } ) def testNoDependencies(self): @@ -107,9 +107,9 @@ configurator, '_getConfigurers', lambda: { - 'a': MockModuleConfigurator('a', set(['b', 'c'])), - 'b': MockModuleConfigurator('b', set()), - 'c': MockModuleConfigurator('c', set()) + 'a': MockModuleConfigurator('a', ['b', 'c']), + 'b': MockModuleConfigurator('b'), + 'c': MockModuleConfigurator('c') } ) def testDependenciesAdditionPositive(self): @@ -126,9 +126,9 @@ configurator, '_getConfigurers', lambda: { - 'a': MockModuleConfigurator('a', set()), - 'b': MockModuleConfigurator('b', set()), - 'c': MockModuleConfigurator('c', set()) + 'a': MockModuleConfigurator('a'), + 'b': MockModuleConfigurator('b'), + 'c': MockModuleConfigurator('c') } ) def testDependenciesAdditionNegative(self): @@ -146,8 +146,8 @@ configurator, '_getConfigurers', lambda: { - 'libvirt': MockModuleConfigurator('libvirt', set()), - 'sanlock': MockModuleConfigurator('sanlock', set()), + 'libvirt': MockModuleConfigurator('libvirt'), + 'sanlock': MockModuleConfigurator('sanlock'), } ) def testNonExistentModule(self): -- To view, visit http://gerrit.ovirt.org/31786 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I11835fe49ffcc3e4cbfdbc4272bc31429b6be2e1 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <nsof...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches