Skip to content

Commit

Permalink
Add exception testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiirola committed Nov 8, 2024
1 parent 23919b1 commit 91ec93f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pyomo/common/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,18 @@ def test_default_function(self):
c.value()

c = ConfigValue('a', domain=int)
with self.assertRaisesRegex(ValueError, 'invalid value for configuration'):
with self.assertRaisesRegex(
ValueError, '(?s)invalid value for configuration.*casting a'
):
c.value()

# Test that if both the default and the result from calling the
# default raise exceptions, the propagated exception is from
# castig the original default:
c = ConfigValue(default=lambda: 'a', domain=int)
with self.assertRaisesRegex(
ValueError, "(?s)invalid value for configuration.*lambda"
):
c.value()

def test_set_default(self):
Expand Down

0 comments on commit 91ec93f

Please sign in to comment.