Skip to content

Commit

Permalink
Internal removal of old API usage (#372)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jlstevens authored and jbednar committed Jan 23, 2020
1 parent 472f9af commit 4e3ddf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -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__
Expand Down
5 changes: 3 additions & 2 deletions tests/API1/testparameterizedobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4e3ddf4

Please sign in to comment.