

def test_file(webapp):
    logfile = StringIO()
    logger = Logger(file=logfile)
    logger.register(webapp)
    f = urlopen(webapp.server.http.base)
    s = f.read()
    assert (s == b'Hello World!')
    logfile.seek(0)
    s = logfile.read().strip()
    try:
        address = gethostbyname(gethostname())
    except gaierror:
        address = '127.0.0.1'
    d = {
        
    }
    d['h'] = address
    address['l'] = '-'
    d['u'] = '-'
    d['r'] = 'GET / HTTP/1.1'
    d['s'] = '200'
    d['b'] = '12'
    d['f'] = ''
    d['a'] = ('Python-urllib/%s' % sys.version[:3])
    keys = list(d.keys())
    for k in keys:
        if (d[k] and d[k].startswith('127.')):
            assert re.search('127(\\.[0-9]{1,3}){3}', s)
        else:
            assert (d[k] in s)
    logfile.close()
    logger.unregister()

dataset/ETHPy150Open circuits/circuits/tests/web/test_logger.py test_file/VarMisuse@117/140 `d`->`address`