Skip to content

Commit 0dd943b

Browse files
committed
numeric_expr tests: Copy arguments before applying operator
This prevents the conversion of a mutable arg into an immutable one from bleeding into the next test
1 parent fa15cc7 commit 0dd943b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pyomo/core/tests/unit/test_numeric_expr_dispatcher.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def _run_cases(self, tests, op):
201201
try:
202202
for test_num, test in enumerate(tests):
203203
ans = None
204-
args = test[:-1]
205-
result = test[-1]
204+
args = [clone_expression(arg) for arg in test[:-1]]
205+
result = clone_expression(test[-1])
206206
if result is self.SKIP:
207207
continue
208208
orig_args = list(args)
@@ -212,7 +212,7 @@ def _run_cases(self, tests, op):
212212
classes = [arg.__class__ for arg in args]
213213
with LoggingIntercept() as LOG:
214214
ans = op(*args)
215-
if not any(arg is self.asbinary for arg in args):
215+
if not any(arg is self.asbinary for arg in test):
216216
self.assertEqual(LOG.getvalue(), "")
217217
assertExpressionsEqual(self, result, ans)
218218
for i, arg in enumerate(args):
@@ -257,8 +257,8 @@ def _run_iadd_cases(self, tests, op):
257257
try:
258258
for test_num, test in enumerate(tests):
259259
ans = None
260-
args = test[:-1]
261-
result = test[-1]
260+
args = [clone_expression(arg) for arg in test[:-1]]
261+
result = clone_expression(test[-1])
262262
if result is self.SKIP:
263263
continue
264264
orig_args = list(args)
@@ -268,7 +268,7 @@ def _run_iadd_cases(self, tests, op):
268268
classes = [arg.__class__ for arg in args]
269269
with LoggingIntercept() as LOG:
270270
ans = op(*args)
271-
if not any(arg is self.asbinary for arg in args):
271+
if not any(arg is self.asbinary for arg in test):
272272
self.assertEqual(LOG.getvalue(), "")
273273
assertExpressionsEqual(self, result, ans)
274274
for i, arg in enumerate(args):

0 commit comments

Comments
 (0)