def test_basic_type(): assert is_instance(5, int)
def test_ellipsis(): assert is_instance(..., 'ellipsis')
def test_union(value, type_, expected): assert is_instance(value, type_) == expected
def test_nested_generics(): assert is_instance(([1.5], 'bar'), Tuple[List[float], str])
def test_any(): assert is_instance(5, Any)
def test_unannotated_callable(value, type_): with pytest.raises(ValueError): is_instance(value, type_)
def test_tuple(): assert is_instance(('bar', True), Tuple[str, bool])
def test_generic_iterable_with_mixed_types(): assert not is_instance([1, 2.5], List[int])
def test_generic_mapping(): assert is_instance({1: 'foo'}, Dict[int, str])
def test_empty_iterable(): assert is_instance([], List[bool])
def test_bounded_typevar(value, bound, expected): var = TypeVar('T', bound=bound) assert is_instance(value, var) == expected
def test_typevar(value, constraints, expected): var = TypeVar('T', *constraints) assert is_instance(value, var) == expected
def test_callable_with_typevars(value, type_, expected): assert is_instance(value, type_) == expected
def test_generic_iterable(): assert is_instance([1, 2], List[int])
def test_supportsX(value, type_, expected): assert is_instance(value, type_) == expected
def test_generic_mapping_detects_wrong_value_type(): assert not is_instance({1: 'foo'}, Dict[int, float])
def test_iterable(value, type_, expected): assert is_instance(value, type_) == expected
def test_typing_type(): assert is_instance([], List)