gauge-python
gauge-python copied to clipboard
[SOS]When i update getgauge==0.3.14,it does not work well(Chinease support is unfriendly)
Describe the bug
A clear and concise description of what the bug is.
Because my project py script contains chinease.
To Reproduce Steps (or project) to reproduce the behavior:
- Initialise a gauge project
- Use the following piece of code
- Run the gauge command
- See error
$ gauge init python
$ gauge run specs
Logs
Paste any log or error messages here
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Versions:
- OS [e.g. 10.15.6 (19G2021) please be specific ]
- Python version 3.8.6
gauge -v
1.1.6
Additional context Add any other context about the problem here.
Is my image broken?
when i pip install -U getgauge==0.3.14, and call gauge run specs
.this is error log, may be encoding='utf-8'
Python: 3.8.6
Failed to parse E:\pyProject\scf-ui-test\step_impl\coal_basic.py: 'gbk' codec can't decode byte 0x80 in position 2385: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\coal_char_impl.py: 'gbk' codec can't decode byte 0x80 in position 161: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\coal_purchase_contract_list_impl.py: 'gbk' codec can't decode byte 0x80 in position 623: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\contract_sign.py: 'gbk' codec can't decode byte 0x86 in position 892: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\core_enr_impl.py: 'gbk' codec can't decode byte 0x80 in position 831: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\login.py: 'gbk' codec can't decode byte 0xac in position 164: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\material.py: 'gbk' codec can't decode byte 0xb7 in position 344: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\menu_url.py: 'gbk' codec can't decode byte 0x80 in position 26: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\supplier_coal_contract_sign_query.py: 'gbk' codec can't decode byte 0x88 in position 1359: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\way_bill.py: 'gbk' codec can't decode byte 0xae in position 412: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\钢贸服务场景_impl.py: 'gbk' codec can't decode byte 0xa7 in position 751: illegal multibyte sequence
Failed to parse E:\pyProject\scf-ui-test\step_impl\util\common.py: 'gbk' codec can't decode byte 0xad in position 229: illegal multibyte sequence
[ValidationError] E:\pyProject\scf-ui-test\specs\concept\web端用户登录.cpt:18 Step implementation not found => '用户打开Ie浏览器,进入登录页面'
[ValidationError] E:\pyProject\scf-ui-test\specs\concept\web端用户登录.cpt:4 Step implementation not found => '依次输入用户名、密码,点击登录按钮
Hi.
I met similar situation. I found a problem, so show relevant infomations.
Environment
Windows 10 Pro 21H1 build 19043.1237 Python 3.9.7 getgauge 0.3.17
Situation
Failed to parse ***\step_impl.py: 'cp932' codec can't decode byte 0x9a in position 1172: illegal multibyte sequence [ValidationError] ***\test.spec:6 Step implementation not found => 'アプリを起動する'
Problem
spec files are encoded by UTF-8, but open() in python uses environment specific codec as default codec. Therefore, open() in getgauge/parse.py need the encoding argument. Below change fixes the problem.
@@ -13,7 +13,7 @@ class Parser(object):
"""
try:
if content is None:
- with open(file_path) as f:
+ with open(file_path, encoding='utf-8') as f:
content = f.read()
py_tree = RedBaron(content)
@knenet02 thanks for pointing that out. Can you send a pull request with this change?