Skip to content

Commit

Permalink
updates to ImmutableConfigValue
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbynum committed Mar 31, 2020
1 parent 00a211b commit 9cc57f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyutilib/misc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,9 @@ def _data_collector(self, level, prefix, visibility=None, docMode=False):

class ImmutableConfigValue(ConfigValue):
def set_value(self, value):
raise RuntimeError(str(self) + ' is currently immutable')
if self._cast(value) != self._data:
raise RuntimeError(str(self) + ' is currently immutable')
super(ImmutableConfigValue, self).set_value(value)

def reset(self):
try:
Expand Down
4 changes: 4 additions & 0 deletions pyutilib/misc/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def test_immutable_config_value(self):
config.a = 4
with self.assertRaises(Exception):
config.b = 5
config.a = 2
config.b = 3
self.assertEqual(config.a, 2)
self.assertEqual(config.b, 3)
locker.release_lock()
config.a = 4
config.b = 5
Expand Down

0 comments on commit 9cc57f0

Please sign in to comment.