Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
de33a8b0
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
de33a8b0
编写于
3月 26, 2018
作者:
A
Amador Pahim
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'clebergnu-encoding_test_fix_v2'
Signed-off-by:
N
Amador Pahim
<
apahim@redhat.com
>
上级
4e8d5826
79d99673
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
7 deletion
+14
-7
avocado/utils/process.py
avocado/utils/process.py
+4
-4
selftests/unit/test_utils_process.py
selftests/unit/test_utils_process.py
+10
-3
未找到文件。
avocado/utils/process.py
浏览文件 @
de33a8b0
...
...
@@ -322,18 +322,18 @@ class CmdResult(object):
@
property
def
stdout_text
(
self
):
if
isinstance
(
self
.
stdout
,
string_types
):
return
self
.
stdout
if
hasattr
(
self
.
stdout
,
'decode'
):
return
self
.
stdout
.
decode
(
self
.
encoding
)
if
isinstance
(
self
.
stdout
,
string_types
):
return
self
.
stdout
raise
TypeError
(
"Unable to decode stdout into a string-like type"
)
@
property
def
stderr_text
(
self
):
if
isinstance
(
self
.
stderr
,
string_types
):
return
self
.
stderr
if
hasattr
(
self
.
stderr
,
'decode'
):
return
self
.
stderr
.
decode
(
self
.
encoding
)
if
isinstance
(
self
.
stderr
,
string_types
):
return
self
.
stderr
raise
TypeError
(
"Unable to decode stderr into a string-like type"
)
def
__repr__
(
self
):
...
...
selftests/unit/test_utils_process.py
浏览文件 @
de33a8b0
...
...
@@ -258,9 +258,16 @@ class TestProcessRun(unittest.TestCase):
# but the behavior is exactly the same as if shell binary
# produced unicode
text
=
u
"Avok
\xe1
do"
result
=
process
.
run
(
"%s %s"
%
(
ECHO_CMD
,
text
),
encoding
=
'utf-8'
)
self
.
assertEqual
(
result
.
stdout
,
text
.
encode
(
'utf-8'
)
+
b
'
\n
'
)
self
.
assertEqual
(
result
.
stdout_text
,
text
+
'
\n
'
)
# Even though code point used is "LATIN SMALL LETTER A WITH ACUTE"
# (http://unicode.scarfboy.com/?s=u%2B00e1) when encoded to proper
# utf-8, it becomes two bytes because it is >= 0x80
# See https://en.wikipedia.org/wiki/UTF-8
encoded_text
=
b
'Avok
\xc3\xa1
do'
self
.
assertEqual
(
text
.
encode
(
'utf-8'
),
encoded_text
)
self
.
assertEqual
(
encoded_text
.
decode
(
'utf-8'
),
text
)
result
=
process
.
run
(
"%s -n %s"
%
(
ECHO_CMD
,
text
),
encoding
=
'utf-8'
)
self
.
assertEqual
(
result
.
stdout
,
encoded_text
)
self
.
assertEqual
(
result
.
stdout_text
,
text
)
class
MiscProcessTests
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录