Robotframework-如何设置语言环境(法语)

时间:2019-04-05 09:26:38

标签: python robotframework

如何设置适用于Windows和Unix的语言环境(法语)?

我的完整机器人测试是:

*** Settings ***
Library    SeleniumLibrary
Library    DateTime

*** Keywords ***
Get Next Week French date
    Evaluate    locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')    locale
    ${today}=               Get Time
    ${tomorrow}=            Add Time To Date  ${today}  1 days
    ${three_day_after}=     Add Time To Date  ${today}  3 days
    ${today_day}=           Convert Date      ${today}  result_format=%a
    Log To Console  ${today_day}
    ${next_date}=           Set Variable If   "${today_day}"=="ven."  ${three_day_after}  ${tomorrow}
    ${next_week}=           Add Time To Date  ${next_date}  7 days
    ${day_of_week}=         Convert Date   ${next_week}  result_format=%A
    ${day_of_week_fr}=      Evaluate  """${day_of_week}""".title()
    ${day}=                 Convert Date   ${next_week}  result_format=%d
    ${month}=               Convert Date   ${next_week}  result_format=%B
    [Return]  ${day_of_week_fr} ${day} ${month} 

test
    ${val}=  Get Next Week French date
    Log To Console  ${val}

*** Test Cases ***

MY SUPER TEST
    [Tags]  foo|AC0
    Given test

在我的本地计算机上(Windows 7)确定

Evaluate    locale.setlocale(locale.LC_ALL, 'french')    locale

在我的CI计算机(Unix)上确定

Evaluate    locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')    locale

如果我在本地计算机上使用fr_FR.UTF-8,则会出现此错误:

locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')' failed: unsupported locale setting

编辑

可能是Python 2(fr_FR.UTF-8)与。 Python 3(法语)??

1 个答案:

答案 0 :(得分:2)

由于Windows和Unix计算机使用不同的语法来设置区域设置,因此您应该首先评估操作系统,然后相应地设置区域设置。

spark-shell