From 4e3ddf41deb92a82148d991321b4429939213084 Mon Sep 17 00:00:00 2001 From: Jean-Luc Stevens Date: Thu, 23 Jan 2020 14:05:37 -0600 Subject: [PATCH] Internal removal of old API usage (#372) * Fixed instance of old API usage in instance bothmethod * Disabled instance parameter warning when stubs error or warn * Updated unit test * Set _disable_stubs to False to warn about old API usage --- param/parameterized.py | 9 +++++---- tests/API1/testparameterizedobject.py | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/param/parameterized.py b/param/parameterized.py index 5124d0250..4297b5337 100644 --- a/param/parameterized.py +++ b/param/parameterized.py @@ -1062,7 +1062,7 @@ class Parameters(object): class or the instance as necessary. """ - _disable_stubs = None # Flag used to disable stubs in the API1 tests + _disable_stubs = False # Flag used to disable stubs in the API1 tests # None for no action, True to raise and False to warn. def __init__(self_, cls, self=None): @@ -1309,9 +1309,10 @@ def params(self_, parameter_name=None): Includes Parameters from this class and its superclasses. """ - if self_.self is not None and self_.self._instance__params: + if (self_.self is not None and self_.self._instance__params + and self_._disable_stubs is None): self_.warning('The Parameterized instance has instance ' - 'parameters created using new-style param ' + 'parameters created using the new-style param ' 'APIs, which are incompatible with .params. ' 'Use the new more explicit APIs on the ' '.param accessor to query parameter instances.' @@ -2794,7 +2795,7 @@ def instance(self_or_cls,**params): cls = self_or_cls else: p = params - params = dict(self_or_cls.get_param_values()) + params = dict(self_or_cls.param.get_param_values()) params.update(p) params.pop('name') cls = self_or_cls.__class__ diff --git a/tests/API1/testparameterizedobject.py b/tests/API1/testparameterizedobject.py index 2362f7e67..f59055e7e 100644 --- a/tests/API1/testparameterizedobject.py +++ b/tests/API1/testparameterizedobject.py @@ -233,8 +233,9 @@ def test_instance_param_objects_warn_on_params(self): inst.param['inst'] inst.param.params() - self.log_handler.assertContains( - 'WARNING', 'The Parameterized instance has instance parameters') + if param.parameterized.Parameters._disable_stubs is None: + self.log_handler.assertContains( + 'WARNING', 'The Parameterized instance has instance parameters') def test_instance_param_getitem(self):