如何设置对 Windows 和 Unix 有效的语言环境(法语)?我的完整机器人测试是:*** Settings ***Library SeleniumLibraryLibrary 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) Vs。Python 3 (法语) ??
1 回答
慕斯709654
TA贡献1840条经验 获得超5个赞
由于 Windows 和 Unix 机器使用不同的语法来设置语言环境,因此您应该首先评估操作系统,然后相应地设置语言环境。
*** Keywords ***
Get next week french date
${osName} Evaluate platform.system() platform
Run keyword if "${osName}"=='Windows' Evaluate locale.setlocale(locale.LC_ALL, 'french') locale
... ELSE Evaluate locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') locale
添加回答
举报
0/150
提交
取消