You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I do the following test, it fails as the content of the input group is not immutable and the next step will still see the changes.
This instead does not work with self.inputs as this is a FrozenDict. If this is the expected behaviour, this should be extended to groups.
As a side note, I think groups were implemented to solve the problem of use_ methods with an additional flag to be passed (e.g.: pseudos) and are now being (mis)used by many users just for organisational purposes, to group together inputs. Is this ok? (This also doesn't perform checks/validations, but I got from @sphuber that maybe in the next version this behaviour changed?)
deftest_immutable_input_groups(self):
""" Check that self.inputs.xxx are not modifiable where xxx is an input_group """test_class=selfclassWf(WorkChain):
@classmethoddefdefine(cls, spec):
super(Wf, cls).define(spec)
spec.input_group('grp')
# Try defining an invalid outlinespec.outline(
cls.s1,
cls.s2,
)
defs1(self):
grp=self.inputs.grp# I manipulate this 'inputs' dict - I expect that in the next step# self.inputs is not changed## If we want the same behavior for group as for inputs, we want these exceptions to be raised## Otherwise, if the dictionary can be changed, still we want the next test (in step s2) to work.withtest_class.assertRaises(TypeError): # 'AttributesFrozendict' object does not support item assignmentgrp['one'] =Int(3)
withtest_class.assertRaises(AttributeError): # AttributeError: 'AttributesFrozendict' object has no attribute 'pop'grp.pop('two')
withtest_class.assertRaises(TypeError): # 'AttributesFrozendict' object does not support item assignmentgrp['four'] =Int(4)
defs2(self):
grp=self.inputs.grp# a and b should be still theretest_class.assertIn('one', grp)
test_class.assertIn('two', grp)
test_class.assertNotIn('four', grp)
# The value should still be the original one, unmodifiedtest_class.assertEquals(grp['one'].value, 1)
x=Int(1)
y=Int(2)
run(Wf, grp={'one': x, 'two': y})
The text was updated successfully, but these errors were encountered:
If I do the following test, it fails as the content of the input group is not immutable and the next step will still see the changes.
This instead does not work with
self.inputs
as this is a FrozenDict. If this is the expected behaviour, this should be extended to groups.As a side note, I think groups were implemented to solve the problem of
use_
methods with an additional flag to be passed (e.g.: pseudos) and are now being (mis)used by many users just for organisational purposes, to group together inputs. Is this ok? (This also doesn't perform checks/validations, but I got from @sphuber that maybe in the next version this behaviour changed?)The text was updated successfully, but these errors were encountered: