class documentation

class TestGenericAlias:

View In Hierarchy

Tests for numpy.typing._generic_alias._GenericAlias.
Method test​_copy Undocumented
Method test​_getattr Test that getattr wraps around the underlying type, aka __origin__.
Method test​_pass Compare types.GenericAlias with its numpy-based backport.
Method test​_raise Test operations that are supposed to raise.
Method test​_weakref Test __weakref__.
@pytest.mark.parametrize('name,func', [('__copy__', (lambda n: n == copy.copy(n))), ('__deepcopy__', (lambda n: n == copy.deepcopy(n)))])
def test_copy(self, name, func):

Undocumented

Parameters
name:strUndocumented
func:FuncTypeUndocumented
@pytest.mark.parametrize('name', GETATTR_NAMES)
def test_getattr(self, name):
Test that getattr wraps around the underlying type, aka __origin__.
Parameters
name:strUndocumented
@pytest.mark.parametrize('name,func', [('__init__', (lambda n: n)), ('__init__', (lambda n: _GenericAlias(np.ndarray, Any))), ('__init__', (lambda n: _GenericAlias(np.ndarray, (Any,)))), ('__init__', (lambda n: _GenericAlias(np.ndarray, (Any, Any)))), ('__init__', (lambda n: _GenericAlias(np.ndarray, T1))), ('__init__', (lambda n: _GenericAlias(np.ndarray, (T1,)))), ('__init__', (lambda n: _GenericAlias(np.ndarray, (T1, T2)))), ('__origin__', (lambda n: n.__origin__)), ('__args__', (lambda n: n.__args__)), ('__parameters__', (lambda n: n.__parameters__)), ('__reduce__', (lambda n: n.__reduce__()[1:])), ('__reduce_ex__', (lambda n: n.__reduce_ex__(1)[1:])), ('__mro_entries__', (lambda n: n.__mro_entries__([object]))), ('__hash__', (lambda n: hash(n))), ('__repr__', (lambda n: repr(n))), ('__getitem__', (lambda n: n[np.float64])), ('__getitem__', (lambda n: n[ScalarType][np.float64])), ('__getitem__', (lambda n: n[Union[np.int64, ScalarType]][np.float64])), ('__getitem__', (lambda n: n[Union[T1, T2]][np.float32, np.float64])), ('__eq__', (lambda n: n == n)), ('__ne__', (lambda n: n != np.ndarray)), ('__dir__', (lambda n: dir(n))), ('__call__', (lambda n: n((1,), np.int64, BUFFER))), ('__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))))])
def test_pass(self, name, func):

Compare types.GenericAlias with its numpy-based backport.

Checker whether func runs as intended and that both GenericAlias and _GenericAlias return the same result.

Parameters
name:strUndocumented
func:FuncTypeUndocumented
@pytest.mark.parametrize('name,exc_type,func', [('__getitem__', TypeError, (lambda n: n[()])), ('__getitem__', TypeError, (lambda n: n[Any, Any])), ('__getitem__', TypeError, (lambda n: n[Any][Any])), ('isinstance', TypeError, (lambda n: isinstance(np.array(1), n))), ('issublass', TypeError, (lambda n: issubclass(np.ndarray, n))), ('setattr', AttributeError, (lambda n: setattr(n, '__origin__', int))), ('setattr', AttributeError, (lambda n: setattr(n, 'test', int))), ('getattr', AttributeError, (lambda n: getattr(n, 'test')))])
def test_raise(self, name, exc_type, func):
Test operations that are supposed to raise.
Parameters
name:strUndocumented
exc​_type:Type[BaseException]Undocumented
func:FuncTypeUndocumented
def test_weakref(self):
Test __weakref__.