|
4 | 4 | """ |
5 | 5 |
|
6 | 6 | import os |
7 | | -from test.helper import check_evaluation, check_evaluation_as_in_cli, session |
| 7 | +from test.helper import check_evaluation, check_evaluation_as_in_cli |
8 | 8 |
|
9 | 9 | import pytest |
10 | 10 |
|
@@ -229,57 +229,60 @@ def test_Attributes_wrong_args(str_expr, arg_count): |
229 | 229 |
|
230 | 230 |
|
231 | 231 | @pytest.mark.parametrize( |
232 | | - ("str_expr", "msgs", "str_expected", "fail_msg"), |
| 232 | + ("str_expr", "msgs", "str_expected", "assert_failure_msg"), |
233 | 233 | [ |
234 | 234 | ("CleanAll[u];CleanAll[v];", None, None, None), |
235 | 235 | ("SetAttributes[{u, v}, Flat];u[x_] := {x};u[]", None, "u[]", None), |
236 | 236 | ("u[a]", None, "{a}", None), |
237 | 237 | ("v[x_] := x;v[]", None, "v[]", None), |
238 | 238 | ("v[a]", None, "a", None), |
239 | 239 | ( |
240 | | - "v[a, b]", |
| 240 | + "Block[{$IterationLimit = 40}, v[a, b]]", |
241 | 241 | None, |
242 | 242 | "v[a, b]", |
243 | | - "in Mathematica: Iteration limit of 4096 exceeded.", |
| 243 | + "Test $IterationLimit catches unbounded expansion", |
244 | 244 | ), |
245 | 245 | ("CleanAll[u];CleanAll[v];", None, None, None), |
246 | 246 | ], |
247 | 247 | ) |
248 | | -def test_private_doctests_attributes(str_expr, msgs, str_expected, fail_msg): |
| 248 | +def test_private_doctests_attributes(str_expr, msgs, str_expected, assert_failure_msg): |
249 | 249 | """ """ |
250 | 250 | check_evaluation( |
251 | 251 | str_expr, |
252 | 252 | str_expected, |
253 | 253 | to_string_expr=True, |
254 | 254 | to_string_expected=True, |
255 | 255 | hold_expected=True, |
256 | | - failure_message=fail_msg, |
| 256 | + failure_message=assert_failure_msg, |
257 | 257 | expected_messages=msgs, |
258 | 258 | ) |
259 | 259 |
|
260 | 260 |
|
261 | 261 | @pytest.mark.parametrize( |
262 | | - ("str_expr", "msgs", "str_expected", "fail_msg"), |
| 262 | + ("str_expr", "msgs", "str_expected", "assert_failure_msg"), |
263 | 263 | [ |
264 | 264 | ("CleanAll[u];CleanAll[v];", None, None, None), |
265 | 265 | ( |
266 | | - "SetAttributes[{u, v}, Flat];u[x_] := {x};u[a, b]", |
267 | | - ("Iteration limit of 1000 exceeded.",), |
| 266 | + "Block[{$IterationLimit=30}, SetAttributes[{u, v}, Flat];u[x_] := {x};u[a, b]]", |
| 267 | + ("Iteration limit of 30 exceeded.",), |
268 | 268 | "$Aborted", |
269 | | - None, |
| 269 | + "Test $IterationLimit catches unbounded expansion using SetDelayed, test 1.", |
| 270 | + ), |
| 271 | + ( |
| 272 | + "Block[{$IterationLimit=20}, u[a, b, c]]", |
| 273 | + ("Iteration limit of 20 exceeded.",), |
| 274 | + "$Aborted", |
| 275 | + "Test $IterationLimit catches unbounded expansion in function call.", |
270 | 276 | ), |
271 | | - ("u[a, b, c]", ("Iteration limit of 1000 exceeded.",), "$Aborted", None), |
272 | 277 | ( |
273 | | - "v[x_] := x;v[a,b,c]", |
274 | | - ("Iteration limit of 1000 exceeded.",), |
| 278 | + "Block[{$IterationLimit=20}, v[x_] := x;v[a,b,c]]", |
| 279 | + ("Iteration limit of 20 exceeded.",), |
275 | 280 | "$Aborted", |
276 | | - "in Mathematica: Iteration limit of 4096 exceeded.", |
| 281 | + "Test $IterationLimit catches unbounded expansion using SetDelayed, test 2.", |
277 | 282 | ), |
278 | 283 | ("CleanAll[u];CleanAll[v];", None, None, None), |
279 | 284 | ], |
280 | 285 | ) |
281 | | -def test_private_doctests_attributes_with_exceptions( |
282 | | - str_expr, msgs, str_expected, fail_msg |
283 | | -): |
284 | | - """These tests check the behavior of $RecursionLimit and $IterationLimit""" |
285 | | - check_evaluation_as_in_cli(str_expr, str_expected, fail_msg, msgs) |
| 286 | +def test_IterationLimit(str_expr, msgs, str_expected, assert_failure_msg): |
| 287 | + """Check the behavior of $RecursionLimit and $IterationLimit""" |
| 288 | + check_evaluation_as_in_cli(str_expr, str_expected, assert_failure_msg, msgs) |
0 commit comments