def httprettified(test=None, allow_net_connect=True):
    """decorator for test functions

    .. tip:: Also available under the alias :py:func:`httpretty.activate`

    :param test: a callable


    example usage with `nosetests <https://nose.readthedocs.io/en/latest/>`_

    .. testcode::

       import sure
       from httpretty import httprettified

       @httprettified
       def test_using_nosetests():
           httpretty.register_uri(
               httpretty.GET,
               'https://httpbin.org/ip'
           )

           response = requests.get('https://httpbin.org/ip')

           response.json().should.equal({
               "message": "HTTPretty :)"
           })

    example usage with `unittest module <https://docs.python.org/3/library/unittest.html>`_

    .. testcode::

       import unittest
       from sure import expect
       from httpretty import httprettified

       @httprettified
       class TestWithPyUnit(unittest.TestCase):
           def test_httpbin(self):
               httpretty.register_uri(httpretty.GET, 'https://httpbin.org/ip')
               response = requests.get('https://httpbin.org/ip')
               expect(response.json()).to.equal({
                   "message": "HTTPretty :)"
               })

    """
    def decorate_unittest_TestCase_setUp(klass):

        # Prefer addCleanup (added in python 2.7), but fall back
        # to using tearDown if it isn't available
        use_addCleanup = hasattr(klass, 'addCleanup')

        original_setUp = (klass.setUp
                          if hasattr(klass, 'setUp')
                          else None)

        def new_setUp(self):
            httpretty.reset()
            httpretty.enable(allow_net_connect)
            if use_addCleanup:
                self.addCleanup(httpretty.disable)
            if original_setUp:
                original_setUp(self)
        klass.setUp = new_setUp

        if not use_addCleanup:
            original_tearDown = (klass.setUp
                                 if hasattr(klass, 'tearDown')
                                 else None)

            def new_tearDown(self):
                httpretty.disable()
                httpretty.reset()
                if original_tearDown:
                    original_tearDown(self)
            klass.tearDown = new_tearDown

        return klass

    def decorate_test_methods(klass):
        for attr in dir(klass):
            if not attr.startswith('test_'):
                continue

            attr_value = getattr(klass, attr)
            if not hasattr(attr_value, "__call__"):
                continue

            setattr(klass, attr, decorate_callable(attr_value))
        return klass

    def is_unittest_TestCase(klass):
        try:
            import unittest
            return issubclass(klass, unittest.TestCase)
        except ImportError:
            return False

    "A decorator for tests that use HTTPretty"
    def decorate_class(klass):
        if is_unittest_TestCase(klass):
            return decorate_unittest_TestCase_setUp(klass)
        return decorate_test_methods(klass)

    def decorate_callable(test):
        @functools.wraps(test)
        def wrapper(*args, **kw):
            with httprettized(allow_net_connect):
                return test(*args, **kw)
        return wrapper

    if isinstance(test, ClassTypes):
        return decorate_class(test)
    elif callable(test):
        return decorate_callable(test)
    return decorate_callable
decorator for test functions

    .. tip:: Also available under the alias :py:func:`httpretty.activate`

    :param test: a callable


    example usage with `nosetests <https://nose.readthedocs.io/en/latest/>`_

    .. testcode::

       import sure
       from httpretty import httprettified

       @httprettified
       def test_using_nosetests():
           httpretty.register_uri(
               httpretty.GET,
               'https://httpbin.org/ip'
           )

           response = requests.get('https://httpbin.org/ip')

           response.json().should.equal({
               "message": "HTTPretty :)"
           })

    example usage with `unittest module <https://docs.python.org/3/library/unittest.html>`_

    .. testcode::

       import unittest
       from sure import expect
       from httpretty import httprettified

       @httprettified
       class TestWithPyUnit(unittest.TestCase):
           def test_httpbin(self):
               httpretty.register_uri(httpretty.GET, 'https://httpbin.org/ip')
               response = requests.get('https://httpbin.org/ip')
               expect(response.json()).to.equal({
                   "message": "HTTPretty :)"
               })