示例#1
0
def _test_re_match_a_word():
    match_str = "class"
    content_str = "classtest this is "
    ret = pyre.re_match_a_word(match_str, content_str)
    real_value = ret.group()
    expect_value = "class"
    pylog.test_compare_value(real_value, expect_value)
示例#2
0
def _test_re_search_re_str():
    match_str = r"b(ab)*"
    content_str = "ababababa"
    ret = pyre.re_search(match_str, content_str)
    real_value = ret.group()
    expect_value = "bababab"
    pylog.test_compare_value(real_value, expect_value)
示例#3
0
def _test_re_search_a_word_tail():
    match_str = "class"
    content_str = "my tailclass atest"
    ret = pyre.re_search_a_word_tail(match_str, content_str)
    real_value = ret.group()
    expect_value = "class"
    pylog.test_compare_value(real_value, expect_value)
示例#4
0
def _test_check_module():
    module_name = "pylog"
    is_install = pymodule.check_is_install_module(module_name)
    pylog.test_compare_value(is_install, True)

    module_name = "pytest"
    is_install = pymodule.check_is_install_module(module_name)
    pylog.test_compare_value(is_install, True)
示例#5
0
def _test_write_read_file():
    write_con = "ok this is my test\n"
    file_object = pyfile.open_file('./test_pyfile/', 'testfile')
    file_object.write(write_con)
    file_object.close()

    file_object = pyfile.open_file('./test_pyfile/', 'testfile', open_type='r')
    con = file_object.read()
    pylog.test_compare_value(con, write_con)
示例#6
0
def _test_get_center_content():
    match_str = ".*?"
    front_str = "aaaa"
    behind_str = "ccc"
    content_str = "aaaat1tccc aaaat2tcccxaaaat3tccclll"
    ret = pyre.get_center_content(front_str, behind_str, content_str,
                                  match_str)
    real_value = ret
    expect_value = "t1t"
    pylog.test_compare_value(real_value, expect_value)
示例#7
0
def _test_re_find_all_center_content2():
    match_str = ".*"
    front_str = "aaaa"
    behind_str = "ccc"
    content_str = "aaaat1tccc aaaat2tcccxaaaat3tccclll"
    ret = pyre.re_find_all_center_content(front_str, behind_str, content_str,
                                          match_str)
    real_value = ret
    expect_value = ['t1tccc aaaat2tcccxaaaat3t']
    pylog.test_compare_value(real_value, expect_value)
示例#8
0
def _test_default():
    content = b"hello world"
    encodeStr = pydec_encry.EncryCode(content)
    real_value = encodeStr
    expect_value = b"QTPkQEyif8xPzalChdHqSQ=="
    pylog.test_compare_value(real_value, expect_value)

    decodeStr = pydec_encry.DecryCode(encodeStr)
    real_value = decodeStr
    expect_value = content
    pylog.test_compare_value(real_value, expect_value)
示例#9
0
def test():
    obj = Animal()
    pylog.test_compare_value("Animal move style is Animal move",obj.move())
    obj = Plant()
    pylog.test_compare_value("Plant move style is Plant just stay",obj.move())
    obj = Cat()
    pylog.test_compare_value("Cat move style is Cat walk",obj.move())
    obj = Dog()
    pylog.test_compare_value("Dog move style is Dog run",obj.move())
    obj = Fish()
    pylog.test_compare_value("Fish move style is Fish swim",obj.move())
示例#10
0
def _test_self_key():
    content = b"hello world"
    pydec_encry.ENCRY_KEY = "12345678"  #need 8 bytes
    encodeStr = pydec_encry.EncryCode(content)
    real_value = encodeStr
    expect_value = b"27Vzf1M8YVkoKD5gjV3wcQ=="
    pylog.test_compare_value(real_value, expect_value)

    decodeStr = pydec_encry.DecryCode(encodeStr)
    real_value = decodeStr
    expect_value = content
    pylog.test_compare_value(real_value, expect_value)
示例#11
0
def _test_sucess():
    url = "http://imgsrc.baidu.com/forum/w%3D580%3B/sign=7dfd5b126a09c93d07f20effaf06f9dc/34fae6cd7b899e51bb592b084fa7d933c9950dd2.jpg"
    (web_status, img_type, img_weight, img_height) = pyimg.get_img_info(url)
    pylog.test_compare_value(web_status, True)
    pylog.test_compare_value(img_type, 'JPEG')
    pylog.test_compare_value(img_weight, 580)
    pylog.test_compare_value(img_height, 580)
示例#12
0
def pickle_test():
    dic = {
        "key": "111",
        "id": 222,
        "value": 333,
        "name": "nihao",
        "age": 18,
    }
    file_name = 'hello'
    ret = pypickle.save(dic, file_name)
    pylog.test_compare_value(True, ret)
    if ret == True:
        dic = pypickle.read(file_name)
        pylog.test_compare_value(18, dic["age"])
示例#13
0
def _test_fail():
    url = "http://mhimg1.mnsfz.com/pic/meihuo/2015-2-20/1/13547560956462979517680.jpg"
    (web_status, img_type, img_weight, img_height) = pyimg.get_img_info(url)
    pylog.test_compare_value(web_status, False)
    pylog.test_compare_value(img_type, 0)
    pylog.test_compare_value(img_weight, 0)
    pylog.test_compare_value(img_height, 0)
示例#14
0
def _json_fail_test():
    test_str = "json fail"
    json_con = pyjson.json_fail(test_str)
    json_dic = pyjson.json_to_dict(json_con)
    pylog.test_compare_value(json_dic["request_method"],"GET")
    pylog.test_compare_value(json_dic["data"],test_str)
    pylog.test_compare_value(json_dic["result"],"fail")
示例#15
0
def _json_method_not_support_test():
    test_str = "method not support"
    json_con = pyjson.json_method_not_support(test_str)
    json_dic = pyjson.json_to_dict(json_con)
    pylog.test_compare_value(json_dic["request_method"],"GET")
    pylog.test_compare_value(json_dic["data"],test_str)
    pylog.test_compare_value(json_dic["result"],"fail")
示例#16
0
def _test_sqlite_table():
    tb_obj = pysqlite.SQLiteTable()
    dic = {'key': 9, 'content': 'test'}
    tb_obj.insert_item_with_dic(dic)
    tb_obj.insert_item(col_names=['key', 'content'], data_value=[10, 'test'])
    tb_obj.insert_item(col_names=['key', 'content'], data_value=[11, 'test'])
    tb_obj.insert_item(col_names=['key', 'content'], data_value=[12, 'test'])
    tb_obj.insert_item(col_names=['key', 'content'], data_value=[13, 'test'])
    tb_obj.insert_item(col_names=['key', 'content'], data_value=[14, 'test'])
    tb_obj.insert_item(col_names=['key', 'content'], data_value=[15, 'test'])

    ret = tb_obj.query_item()
    real_value = len(ret)
    expect_value = 7
    pylog.test_compare_value(real_value, expect_value)

    ret = tb_obj.delete_item("tb_id=4")
    real_value = ret
    expect_value = True
    pylog.test_compare_value(real_value, expect_value)

    ret = tb_obj.query_item()
    real_value = len(ret)
    expect_value = 6
    pylog.test_compare_value(real_value, expect_value)

    ret = tb_obj.update_item(update_str='content="updatewa"',
                             key_str='tb_id=2')
    real_value = ret
    expect_value = True
    pylog.test_compare_value(real_value, expect_value)

    ret = tb_obj._drop_table()
    real_value = ret
    expect_value = True
    pylog.test_compare_value(real_value, expect_value)

    ret = tb_obj.database_name
    os.popen("rm %s.db" % ret)
示例#17
0
def sqlObjectTest():
    tb_obj = pymysqldb.SQLTable()
    dic = {}
    dic['pid'] = 5
    dic['name'] = 'test'
    ret = tb_obj.insert_item_with_dic(dic)
    pylog.test_compare_value(True, ret)
    tb_obj.insert_item(col_names=['pid', 'name'], data_value=[4, 'test'])
    pylog.test_compare_value(True, ret)
    tb_obj.insert_item(col_names=['pid', 'name'], data_value=[3, 'test'])
    pylog.test_compare_value(True, ret)
    tb_obj.insert_item(col_names=['pid', 'name'], data_value=[6, 'test'])
    pylog.test_compare_value(True, ret)
    ret = tb_obj.delete_item("pid=4")
    pylog.test_compare_value(True, ret)
    ret = tb_obj.update_item(update_str='name="update_name"', key_str='pid=3')
    pylog.test_compare_value(True, ret)
    ret = tb_obj.update_item()
    pylog.test_compare_value(False, ret)
    query_content = tb_obj.query_item()
    ret = len(query_content)
    pylog.test_compare_value(3, ret)

    #   if query_content:
    #       for row in query_content:
    #           print(row)
    ret = tb_obj._drop_table()
    pylog.test_compare_value(True, ret)
    ret = tb_obj._drop_database()
    pylog.test_compare_value(True, ret)
示例#18
0
def test():
    pylog.test_compare_value(pyjson_data.JSON_TYPE_OK, "ok")
    pylog.test_compare_value(pyjson_data.JSON_TYPE_FAIL, "fail")
    pylog.test_compare_value(pyjson_data.JSON_KEY_RESULT, "result")
    pylog.test_compare_value(pyjson_data.JSON_KEY_DATA, "data")
    pylog.test_compare_value(pyjson_data.JSON_KEY_STATE, "state")
    pylog.test_compare_value(pyjson_data.REQUEST_METHOD, "request_method")
    pylog.test_compare_value(pyjson_data.REQUEST_METHOD_NOT_SUPPORT, "http method not support")
    pylog.test_compare_value(pyjson_data.REQUEST_GET, "GET")
    pylog.test_compare_value(pyjson_data.REQUEST_POST, "POST")

    pylog.test_compare_value(pyjson_data.NO_DESCRIPTION, "no description")
示例#19
0
def _test_get_file_full_name():
    test_file_path = "./test_pyfile/test"
    test_file_name = "test.py"
    file_name = pyfile.get_file_full_name(test_file_path, test_file_name)
    pylog.test_compare_value(file_name, "./test_pyfile/test/test.py")
    file_object = pyfile.open_file(test_file_path, test_file_name)
示例#20
0
def _test_http_get():
    url = "http://www.baidu.com"
    is_sucess, ret = pyhttp.http_get(url)
    pylog.test_compare_value(is_sucess, True)
示例#21
0
def _test_nohup_start_python_progress():
    progress_name = "yourname"
    ret = pyprocess.nohup_start_python_progress(progress_name)
    pylog.test_compare_value(ret, True)
示例#22
0
def _test_re_match_first_one_word():
    content_str = "string goes here"
    ret = pyre.re_match_first_one_word(content_str)
    real_value = ret.group()
    expect_value = "string"
    pylog.test_compare_value(real_value, expect_value)
示例#23
0
def _test_re_match_first_one_word2():
    content_str = "23 45 414 45 "
    ret = pyre.re_match_first_one_word(content_str)
    real_value = ret
    expect_value = None
    pylog.test_compare_value(real_value, expect_value)
示例#24
0
def _get_inner_ip_test():
    info = pylinux.get_inner_ip()
    pylog.test_compare_value(info, "127.0.1.1")
    _show_test("内网ip", info)