Merge pull request #1690 from ntjess/master
revert to old behavior: default created from value if not present
This commit is contained in:
commit
3ed206fa70
@ -201,6 +201,7 @@ class Parameter(QtCore.QObject):
|
||||
|
||||
if 'default' not in self.opts:
|
||||
self.opts['default'] = None
|
||||
self.setDefault(self.opts['value'])
|
||||
|
||||
## Connect all state changed signals to the general sigStateChanged
|
||||
self.sigValueChanged.connect(self._emitValueChanged)
|
||||
|
@ -8,32 +8,23 @@ def test_parameter_hasdefault():
|
||||
|
||||
# default unspecified
|
||||
p = Parameter(**opts)
|
||||
assert not p.hasDefault()
|
||||
|
||||
p.setDefault(1)
|
||||
assert p.hasDefault()
|
||||
assert p.defaultValue() == 1
|
||||
assert p.defaultValue() == opts["value"]
|
||||
|
||||
p.setDefault(2)
|
||||
assert p.hasDefault()
|
||||
assert p.defaultValue() == 2
|
||||
|
||||
# default specified
|
||||
p = Parameter(default=0, **opts)
|
||||
assert p.hasDefault()
|
||||
assert p.defaultValue() == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('passdefault', [True, False])
|
||||
def test_parameter_hasdefault_none(passdefault):
|
||||
# test that Parameter essentially ignores defualt=None, same as not passing
|
||||
# a default at all
|
||||
opts = {'name': 'param', 'type': int, 'value': 0}
|
||||
if passdefault:
|
||||
opts['default'] = None
|
||||
|
||||
p = Parameter(**opts)
|
||||
# default specified as None
|
||||
p = Parameter(default=None, **opts)
|
||||
assert not p.hasDefault()
|
||||
assert p.defaultValue() is None
|
||||
|
||||
p.setDefault(None)
|
||||
assert not p.hasDefault()
|
||||
|
||||
|
||||
def test_unpack_parameter():
|
||||
# test that **unpacking correctly returns child name/value maps
|
||||
|
Loading…
Reference in New Issue
Block a user