Skip to content

Commit 1bd8db1

Browse files
authored
Merge pull request #283 from numpy/numpy.testing.TestCase-workaround
🤡 also apply the `unittest.TestCase` workaround to `numpy.testing.TestCase`
2 parents 82aa178 + 65e7d1e commit 1bd8db1

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

src/numpy-stubs/ma/testutils.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from unittest import TestCase as _TestCase
2-
31
import numpy as np
42
import numpy.typing as npt
5-
from numpy.testing import assert_, assert_allclose, assert_array_almost_equal_nulp, assert_raises
3+
from numpy.testing import TestCase, assert_, assert_allclose, assert_array_almost_equal_nulp, assert_raises
64
from numpy.testing._private.utils import _ComparisonFunc
75

86
__all__ = [
@@ -66,6 +64,3 @@ def assert_mask_equal(m1: object, m2: object, err_msg: str = "") -> None: ...
6664

6765
assert_not_equal = fail_if_equal
6866
assert_close = assert_almost_equal
69-
70-
class TestCase(_TestCase):
71-
def __init_subclass__(cls, *args: object, **kwargs: object) -> None: ...

src/numpy-stubs/testing/__init__.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest import TestCase
1+
from unittest import TestCase as _TestCase
22

33
from . import overrides
44
from ._private.utils import (
@@ -100,3 +100,7 @@ __all__ = [
100100
"temppath",
101101
"verbose",
102102
]
103+
104+
# workaround for incorrect typeshed definition
105+
class TestCase(_TestCase):
106+
def __init_subclass__(cls, *args: object, **kwargs: object) -> None: ...

test/static/accept/testing.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,3 @@ assert_type(np.testing.assert_no_gc_cycles(), contextlib._GeneratorContextManage
190190
assert_type(np.testing.assert_no_gc_cycles(func3, 5), None)
191191

192192
assert_type(np.testing.break_cycles(), None)
193-
194-
assert_type(np.testing.TestCase(), unittest.case.TestCase)

tool/.mypyignore.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ numpy\.testing(\._private\.utils)?\.check_support_sve
3232

3333
# stdlib re-exports with incorrect typeshed stubs
3434
numpy\.compat(\.py3k)?\.os_PathLike\.__class_getitem__
35-
numpy\.testing\.TestCase\.__init_subclass__

0 commit comments

Comments
 (0)