

def teardown(host=None, port=None):
    'Remove an installed WSGI hook for ``host`` and ```port``.\n\n    If no host or port is passed, the default values will be assumed.\n    If no hook is installed for the defaults, and both the host and\n    port are missing, the last hook installed will be removed.\n\n    Returns True if a hook was removed, otherwise False.\n    '
    both_missing = ((not host) and (not port))
    host = (host or DEFAULT_HOST)
    port = (port or DEFAULT_PORT)
    key = (host, port)
    key_to_delete = None
    if (key in INSTALLED):
        key_to_delete = key
    if ((not (key in INSTALLED)) and both_missing and (len(INSTALLED) > 0)):
        (host, port) = key_to_delete = INSTALLED.keys()[(- 1)]
    if key_to_delete:
        (_, old_propagate) = INSTALLED[key_to_delete]
        del INSTALLED[key_to_delete]
        result = True
        if (old_propagate is not None):
            settings.DEBUG_PROPAGATE_EXCEPTIONS = old_propagate
    else:
        result = False
    twill.remove_wsgi_intercept(host, port)
    return result

dataset/ETHPy150Open ericholscher/django-test-utils/test_utils/utils/twill_runner.py teardown/original