()
| 1461 | |
| 1462 | |
| 1463 | def test_suppress_warnings_forwarding(): |
| 1464 | def warn_other_module(): |
| 1465 | # Apply along axis is implemented in python; stacklevel=2 means |
| 1466 | # we end up inside its module, not ours. |
| 1467 | def warn(arr): |
| 1468 | warnings.warn("Some warning", stacklevel=2) |
| 1469 | return arr |
| 1470 | np.apply_along_axis(warn, 0, [0]) |
| 1471 | |
| 1472 | with suppress_warnings() as sup: |
| 1473 | sup.record() |
| 1474 | with suppress_warnings("always"): |
| 1475 | for i in range(2): |
| 1476 | warnings.warn("Some warning") |
| 1477 | |
| 1478 | assert_equal(len(sup.log), 2) |
| 1479 | |
| 1480 | with suppress_warnings() as sup: |
| 1481 | sup.record() |
| 1482 | with suppress_warnings("location"): |
| 1483 | for i in range(2): |
| 1484 | warnings.warn("Some warning") |
| 1485 | warnings.warn("Some warning") |
| 1486 | |
| 1487 | assert_equal(len(sup.log), 2) |
| 1488 | |
| 1489 | with suppress_warnings() as sup: |
| 1490 | sup.record() |
| 1491 | with suppress_warnings("module"): |
| 1492 | for i in range(2): |
| 1493 | warnings.warn("Some warning") |
| 1494 | warnings.warn("Some warning") |
| 1495 | warn_other_module() |
| 1496 | |
| 1497 | assert_equal(len(sup.log), 2) |
| 1498 | |
| 1499 | with suppress_warnings() as sup: |
| 1500 | sup.record() |
| 1501 | with suppress_warnings("once"): |
| 1502 | for i in range(2): |
| 1503 | warnings.warn("Some warning") |
| 1504 | warnings.warn("Some other warning") |
| 1505 | warn_other_module() |
| 1506 | |
| 1507 | assert_equal(len(sup.log), 2) |
| 1508 | |
| 1509 | |
| 1510 | def test_tempdir(): |
nothing calls this directly
no test coverage detected