Пример #1
0
def test():
    #url = 'http://localhost/404/'
    #url = 'http://localhost/sleep.py?t=5'
    url = util.get_request_param('url')
    if url is None:
        url = 'http://localhost/test/'
    ret = url + '\n'
    try:
        ret += 'test_http_request() = \n' + util.convert_newline(
            test_http_request(url), '\n') + '\n'
        ret += 'test_http_request2() = \n' + util.convert_newline(
            test_http_request2(url), '\n') + '\n'
    except Exception as e:
        code = ''
        if hasattr(e, 'code'):
            code = str(e.code)

        reason = ''
        if hasattr(e, 'reason'):
            reason = str(e.reason)

        ret += 'test_http_request() = ' + str(
            e) + ' / ' + code + ' ' + reason + '\n'

    ret += 'test_get_proxies() = ' + str(test_get_proxies()) + '\n'
    ret += '\n'

    return ret
Пример #2
0
def test():
    cmd = 'dir'
    ret = ''
    ret += '\n' + util.convert_newline(util.exec_cmd(cmd), '\n')
    ret += '\n'
    ret += '\n' + util.convert_newline(
        util.exec_cmd(cmd, encoding='shift_jis'), '\n')
    return ret
Пример #3
0
def test_convert_newline():
    ret = '\n'
    ret += 'lf=\n'
    ret += util.convert_newline('A\r\nB\nC\rD', '\n')
    ret += '\n\ncrlf=\n'
    ret += util.convert_newline('A\r\nB\nC\rD', '\r\n')
    ret += '\n\ncr=\n'
    ret += util.convert_newline('A\r\nB\nC\rD', '\r')
    ret += '\n\nbr=\n'
    ret += util.convert_newline('A\r\nB\nC\rD', '<br>')
    return ret