From 7ad8b8522b94c02d41fc0e8d7dff95f4eda89e80 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Wed, 3 Feb 2016 14:59:49 +0000 Subject: [PATCH 1/2] AttributeCollection: No longer allows duplicate overriding attributes Previously if parameters with the same names and override set to True were added to an extension at the same level one would silently override the other. This is no longer the case and an error will be show instead. Also added tests to check that this is handeled correctly --- wlauto/core/extension.py | 6 +++++- wlauto/tests/test_extension.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wlauto/core/extension.py b/wlauto/core/extension.py index 3aed90dc..348a5b9f 100644 --- a/wlauto/core/extension.py +++ b/wlauto/core/extension.py @@ -82,7 +82,12 @@ class AttributeCollection(object): return p def __iadd__(self, other): + other = [self._to_attrcls(p) for p in other] + names = [] for p in other: + if p.name in names: + raise ValueError("Duplicate '{}' {}".format(p.name, p.__class__.__name__.split('.')[-1])) + names.append(p.name) self.add(p) return self @@ -687,4 +692,3 @@ class Module(Extension): def initialize(self, context): pass - diff --git a/wlauto/tests/test_extension.py b/wlauto/tests/test_extension.py index 77e244f6..dee00cc4 100644 --- a/wlauto/tests/test_extension.py +++ b/wlauto/tests/test_extension.py @@ -320,6 +320,13 @@ class ParametersTest(TestCase): myext = _instantiate(MyOtherExtension, mandatory=1, optional='invalid') myext.validate() + @raises(ValueError) + def test_duplicate_param_override(self): + class DuplicateParamExtension(MyBaseExtension): # pylint: disable=W0612 + parameters = [ + Parameter('food', override=True, default='cheese'), + Parameter('food', override=True, default='cheese'), + ] class ModuleTest(TestCase): @@ -340,4 +347,3 @@ class ModuleTest(TestCase): def _instantiate(cls, *args, **kwargs): # Needed to get around Extension's __init__ checks return cls(*args, **kwargs) - From dec574e59e707fccb9bd8f2c4f7edb0e55938a57 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Wed, 3 Feb 2016 11:23:21 +0000 Subject: [PATCH 2/2] AndroidDevice: Removed duplicate parameter --- wlauto/common/android/device.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/wlauto/common/android/device.py b/wlauto/common/android/device.py index d3d3684e..f5dab842 100644 --- a/wlauto/common/android/device.py +++ b/wlauto/common/android/device.py @@ -78,8 +78,6 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 If set a swipe of the specified direction will be performed. This should unlock the screen. """), - Parameter('binaries_directory', default="/data/local/tmp", override=True, - description='Location of executable binaries on this device (must be in PATH).'), ] default_timeout = 30