def assert_valid_input ( cls , tag ) : # Fail on unexpected types. if not cls . is_tag ( tag ) : raise TypeError ( "Expected a BeautifulSoup 'Tag', but instead recieved type {}" . format ( type ( tag ) ) )
python test the type of input
Check if valid input tag or document .
def assert_valid_input(cls, tag):
        """Check if valid input tag or document."""

        # Fail on unexpected types.
        if not cls.is_tag(tag):
            raise TypeError("Expected a BeautifulSoup 'Tag', but instead recieved type {}".format(type(tag)))