Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Fix a GenericAlias test failure for python 3.9.0 #19501

Merged
merged 1 commit into from Jul 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion numpy/typing/tests/test_generic_alias.py
Expand Up @@ -60,7 +60,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.
Expand All @@ -75,6 +74,14 @@ def test_pass(self, name: str, func: FuncType) -> None:
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,
Expand Down