|
9 | 9 | from itertools import product |
10 | 10 | from numpy.testing import ( |
11 | 11 | assert_, assert_equal, assert_raises, assert_array_equal, assert_warns, |
12 | | - HAS_REFCOUNT, suppress_warnings, |
| 12 | + HAS_REFCOUNT, |
13 | 13 | ) |
14 | 14 |
|
15 | 15 |
|
@@ -669,30 +669,16 @@ def __setitem__(self, indx, val): |
669 | 669 | k[0:5] |
670 | 670 | assert_equal(k.indx, slice(0, 5)) |
671 | 671 | assert_equal(sys.getrefcount(k.indx), 2) |
672 | | - try: |
| 672 | + with assert_raises(ValueError): |
673 | 673 | k[0:7] |
674 | | - raise AssertionError |
675 | | - except ValueError: |
676 | | - # The exception holds a reference to the slice so clear on Py2 |
677 | | - if hasattr(sys, 'exc_clear'): |
678 | | - with suppress_warnings() as sup: |
679 | | - sup.filter(DeprecationWarning) |
680 | | - sys.exc_clear() |
681 | 674 | assert_equal(k.indx, slice(0, 7)) |
682 | 675 | assert_equal(sys.getrefcount(k.indx), 2) |
683 | 676 |
|
684 | 677 | k[0:3] = 6 |
685 | 678 | assert_equal(k.indx, slice(0, 3)) |
686 | 679 | assert_equal(sys.getrefcount(k.indx), 2) |
687 | | - try: |
| 680 | + with assert_raises(ValueError): |
688 | 681 | k[0:4] = 2 |
689 | | - raise AssertionError |
690 | | - except ValueError: |
691 | | - # The exception holds a reference to the slice so clear on Py2 |
692 | | - if hasattr(sys, 'exc_clear'): |
693 | | - with suppress_warnings() as sup: |
694 | | - sup.filter(DeprecationWarning) |
695 | | - sys.exc_clear() |
696 | 682 | assert_equal(k.indx, slice(0, 4)) |
697 | 683 | assert_equal(sys.getrefcount(k.indx), 2) |
698 | 684 |
|
|
0 commit comments