def assert_is_instance(obj, cls, msg_fmt="{msg}"):
    """Fail if an object is not an instance of a class or tuple of classes.

    >>> assert_is_instance(5, int)
    >>> assert_is_instance('foo', (str, bytes))
    >>> assert_is_instance(5, str)
    Traceback (most recent call last):
        ...
    AssertionError: 5 is an instance of <class 'int'>, expected <class 'str'>

    The following msg_fmt arguments are supported:
    * msg - the default error message
    * obj - object to test
    * types - tuple of types tested against
    """
    if not isinstance(obj, cls):
        msg = "{!r} is an instance of {!r}, expected {!r}".format(
            obj, obj.__class__, cls
        )
        types = cls if isinstance(cls, tuple) else (cls,)
        fail(msg_fmt.format(msg=msg, obj=obj, types=types))
def assert_is_instance ( obj , cls , msg_fmt = "{msg}" ) : if not isinstance ( obj , cls ) : msg = "{!r} is an instance of {!r}, expected {!r}" . format ( obj , obj . __class__ , cls ) types = cls if isinstance ( cls , tuple ) else ( cls , ) fail ( msg_fmt . format ( msg = msg , obj = obj , types = types ) )
Fail if an object is not an instance of a class or tuple of classes.

    >>> assert_is_instance(5, int)
    >>> assert_is_instance('foo', (str, bytes))
    >>> assert_is_instance(5, str)
    Traceback (most recent call last):
        ...
    AssertionError: 5 is an instance of <class 'int'>, expected <class 'str'>

    The following msg_fmt arguments are supported:
    * msg - the default error message
    * obj - object to test
    * types - tuple of types tested against