diff options
| author | Matti Picus <matti.picus@gmail.com> | 2021-07-12 13:01:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-12 13:01:21 +0300 |
| commit | bb71b5fb7b65b662c1fffa3f8120cbfd02e2c164 (patch) | |
| tree | d6583298ea232b4b38a89c72ee8d587b9800b140 | |
| parent | e20b8c64cd5151851d14f090a4eeedca2efebe03 (diff) | |
| parent | 263a97c620f9d469f1b35d42af048794b036e03b (diff) | |
| download | numpy-bb71b5fb7b65b662c1fffa3f8120cbfd02e2c164.tar.gz | |
Merge pull request #19456 from BvB93/weakref
TST: Fix a `GenericAlias` test failure for python 3.9.0
| -rw-r--r-- | numpy/typing/tests/test_generic_alias.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py index 538d7eae5..3021d9859 100644 --- a/numpy/typing/tests/test_generic_alias.py +++ b/numpy/typing/tests/test_generic_alias.py @@ -66,7 +66,6 @@ class TestGenericAlias: ("__call__", lambda n: n(shape=(1,), dtype=np.int64, buffer=BUFFER)), ("subclassing", lambda n: _get_subclass_mro(n)), ("pickle", lambda n: n == pickle.loads(pickle.dumps(n))), - ("__weakref__", lambda n: n == weakref.ref(n)()), ]) def test_pass(self, name: str, func: FuncType) -> None: """Compare `types.GenericAlias` with its numpy-based backport. @@ -81,6 +80,14 @@ class TestGenericAlias: value_ref = func(NDArray_ref) assert value == value_ref + def test_weakref(self) -> None: + """Test ``__weakref__``.""" + value = weakref.ref(NDArray)() + + if sys.version_info >= (3, 9, 1): # xref bpo-42332 + value_ref = weakref.ref(NDArray_ref)() + assert value == value_ref + @pytest.mark.parametrize("name", GETATTR_NAMES) def test_getattr(self, name: str) -> None: """Test that `getattr` wraps around the underlying type, |
