|
| 1 | +import re |
1 | 2 | from warnings import catch_warnings
|
2 | 3 |
|
3 | 4 | import numpy as np
|
@@ -49,13 +50,28 @@ class TestABCClasses:
|
49 | 50 |
|
50 | 51 | @pytest.mark.parametrize("abctype1, inst", abc_pairs)
|
51 | 52 | @pytest.mark.parametrize("abctype2, _", abc_pairs)
|
52 |
| - def test_abc_pairs(self, abctype1, abctype2, inst, _): |
53 |
| - # GH 38588 |
| 53 | + def test_abc_pairs_instance_check(self, abctype1, abctype2, inst, _): |
| 54 | + # GH 38588, 46719 |
54 | 55 | if abctype1 == abctype2:
|
55 | 56 | assert isinstance(inst, getattr(gt, abctype2))
|
| 57 | + assert not isinstance(type(inst), getattr(gt, abctype2)) |
56 | 58 | else:
|
57 | 59 | assert not isinstance(inst, getattr(gt, abctype2))
|
58 | 60 |
|
| 61 | + @pytest.mark.parametrize("abctype1, inst", abc_pairs) |
| 62 | + @pytest.mark.parametrize("abctype2, _", abc_pairs) |
| 63 | + def test_abc_pairs_subclass_check(self, abctype1, abctype2, inst, _): |
| 64 | + # GH 38588, 46719 |
| 65 | + if abctype1 == abctype2: |
| 66 | + assert issubclass(type(inst), getattr(gt, abctype2)) |
| 67 | + |
| 68 | + with pytest.raises( |
| 69 | + TypeError, match=re.escape("issubclass() arg 1 must be a class") |
| 70 | + ): |
| 71 | + issubclass(inst, getattr(gt, abctype2)) |
| 72 | + else: |
| 73 | + assert not issubclass(type(inst), getattr(gt, abctype2)) |
| 74 | + |
59 | 75 | abc_subclasses = {
|
60 | 76 | "ABCIndex": [
|
61 | 77 | abctype
|
|
0 commit comments