zoukankan      html  css  js  c++  java
  • 【RF库测试】Encode String To Bytes&Decode Bytes To String& should be string&should be unicode string &should not be string

    场景1:判断类型

    r
    ${d} set variable xbaxcbxbcxf5xcdxa8xb9xfd #核减通过
    Run Keyword And Continue On Failure should be byte string ${d}
    should be string ${d}
    Should Be Unicode String ${d}
    Run Keyword And Continue On Failure Should Not Be String ${d}
    ${e} set variable 核减通过
    Run Keyword And Continue On Failure should be byte string ${e}
    should be string ${e}
    Should Be Unicode String ${e}
    Run Keyword And Continue On Failure Should Not Be String ${e}

    总结:两个变量均为string 和 unicode string类型,而非byte string类型;

    场景2:Encode String To Bytes

    e
    ${d} set variable xbaxcbxbcxf5xcdxa8xb9xfd
    ${dUTF8} Encode String To Bytes ${d} UTF-8
    ${dASCII} Encode String To Bytes ${d} ASCII errors=ignore
    ${e} set variable 核减通过
    ${eUTF8} Encode String To Bytes ${e} UTF-8
    ${eASCII} Run Keyword And Continue On Failure Encode String To Bytes ${e} ASCII
    Run Keyword And Continue On Failure should be equal ${eUTF8} ${dUTF8}
    Run Keyword And Continue On Failure should be equal ${eASCII} ${dASCII}

    执行结果:

    Starting test: ZXJF.清结算 一期.互联网核减.e
    20170712 11:33:08.790 : INFO : ${d} = xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:33:08.790 : INFO : ${dUTF8} = xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:33:08.790 : INFO : ${dASCII} = xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:33:08.790 : INFO : ${e} = 核减通过
    20170712 11:33:08.790 : INFO : ${eUTF8} = xe6xa0xb8xe5x87x8fxe9x80x9axe8xbfx87
    20170712 11:33:08.806 : FAIL : UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
    20170712 11:33:08.806 : INFO : ${eASCII} = None
    20170712 11:33:08.806 : INFO :
    Argument types are:
    <type 'str'>
    <type 'str'>
    20170712 11:33:08.806 : FAIL : xe6xa0xb8xe5x87x8fxe9x80x9axe8xbfx87 != xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:33:08.806 : INFO :
    Argument types are:
    <type 'NoneType'>
    <type 'str'>
    20170712 11:33:08.806 : FAIL : None != xbaxcbxbcxf5xcdxa8xb9xfd
    Ending test: ZXJF.清结算 一期.互联网核减.e

    场景3:Decode Bytes To String

    t
    ${d} set variable xbaxcbxbcxf5xcdxa8xb9xfd
    ${dUTF8} Decode Bytes To String ${d} UTF-8
    ${dASCII} Decode Bytes To String ${d} ASCII errors=ignore
    ${e} set variable 核减通过
    ${eUTF8} Run Keyword And Continue On Failure Decode Bytes To String ${e} UTF-8
    ${eASCII} Run Keyword And Continue On Failure Decode Bytes To String ${e} ASCII errors=ignore
    Run Keyword And Continue On Failure should be equal ${eUTF8} ${dUTF8}
    Run Keyword And Continue On Failure should be equal ${eASCII} ${dASCII}

    执行结果: 

    Starting test: ZXJF.清结算 一期.互联网核减.t
    20170712 11:31:33.780 : INFO : ${d} = xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:31:33.780 : INFO : ${dUTF8} = xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:31:33.780 : INFO : ${dASCII} = xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:31:33.780 : INFO : ${e} = 核减通过
    20170712 11:31:33.780 : FAIL : UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
    20170712 11:31:33.796 : INFO : ${eUTF8} = None
    20170712 11:31:33.796 : FAIL : UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
    20170712 11:31:33.796 : INFO : ${eASCII} = None
    20170712 11:31:33.796 : INFO :
    Argument types are:
    <type 'NoneType'>
    <type 'unicode'>
    20170712 11:31:33.796 : FAIL : None != xbaxcbxbcxf5xcdxa8xb9xfd
    20170712 11:31:33.796 : INFO :
    Argument types are:
    <type 'NoneType'>
    <type 'unicode'>
    20170712 11:31:33.812 : FAIL : None != xbaxcbxbcxf5xcdxa8xb9xfd
    Ending test: ZXJF.清结算 一期.互联网核减.t

  • 相关阅读:
    【转】VS2010中 C++创建DLL图解
    [转]error: 'retainCount' is unavailable: not available in automatic reference counting mode
    [转]关于NSAutoreleasePool' is unavailable: not available in automatic reference counting mode的解决方法
    【转】 Tomcat v7.0 Server at localhost was unable to start within 45
    【转】Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If
    【转】SVN管理多个项目版本库
    【转】eclipse安装SVN插件的两种方法
    【转】MYSQL启用日志,和查看日志
    【转】Repository has not been enabled to accept revision propchanges
    【转】SVN库的迁移
  • 原文地址:https://www.cnblogs.com/apple2016/p/7154514.html
Copyright © 2011-2022 走看看