Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
561647d2
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,发现更多精彩内容 >>
未验证
提交
561647d2
编写于
4月 23, 2019
作者:
J
Jan Richter
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'clebergnu/runner_and_test_misc'
Signed-off-by:
N
Jan Richter
<
jarichte@redhat.com
>
上级
b8451aef
a4bc8353
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
65 addition
and
65 deletion
+65
-65
avocado/core/runner.py
avocado/core/runner.py
+5
-12
selftests/unit/test_runner_queue.py
selftests/unit/test_runner_queue.py
+1
-4
selftests/unit/test_test.py
selftests/unit/test_test.py
+59
-49
未找到文件。
avocado/core/runner.py
浏览文件 @
561647d2
...
...
@@ -17,7 +17,7 @@
Test runner module.
"""
import
multiprocessing
.queues
import
multiprocessing
import
os
import
signal
import
sys
...
...
@@ -582,14 +582,7 @@ class TestRunner:
summary
=
set
()
if
self
.
job
.
sysinfo
is
not
None
:
self
.
job
.
sysinfo
.
start_job_hook
()
# Python 3 can choose a context type for queues, but SimpleQueue
# lives directly under the module namespace
if
hasattr
(
multiprocessing
,
'SimpleQueue'
):
queue
=
multiprocessing
.
SimpleQueue
()
else
:
queue
=
multiprocessing
.
queues
.
SimpleQueue
()
# pylint: disable=E1125
if
timeout
>
0
:
deadline
=
time
.
time
()
+
timeout
else
:
...
...
@@ -600,9 +593,9 @@ class TestRunner:
self
.
result
.
tests_total
=
test_result_total
index
=
-
1
try
:
for
test_
template
in
test_suite
:
test_
template
[
1
][
"base_logdir"
]
=
self
.
job
.
logdir
test_
template
[
1
][
"job"
]
=
self
.
job
for
test_
factory
in
test_suite
:
test_
factory
[
1
][
"base_logdir"
]
=
self
.
job
.
logdir
test_
factory
[
1
][
"job"
]
=
self
.
job
if
execution_order
is
None
:
execution_order
=
self
.
DEFAULT_EXECUTION_ORDER
for
test_factory
,
variant
in
self
.
_iter_suite
(
test_suite
,
variants
,
...
...
selftests/unit/test_runner_queue.py
浏览文件 @
561647d2
...
...
@@ -34,10 +34,7 @@ class TestRunnerQueue(unittest.TestCase):
:param factory: the Avocado Test factory
:return: the last queue message from the test
"""
if
hasattr
(
multiprocessing
,
'SimpleQueue'
):
queue
=
multiprocessing
.
SimpleQueue
()
else
:
queue
=
multiprocessing
.
queues
.
SimpleQueue
()
# pylint: disable=E1125
runner
=
TestRunner
(
job
=
self
.
job
,
result
=
self
.
result
)
runner
.
_run_test
(
factory
,
queue
)
while
not
queue
.
empty
():
...
...
selftests/unit/test_test.py
浏览文件 @
561647d2
...
...
@@ -248,59 +248,69 @@ class SimpleTestClassTest(unittest.TestCase):
class
MockingTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tests
=
[]
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
def
test_init_minimal_params
(
self
):
test
.
MockingTest
(
base_logdir
=
self
.
tmpdir
)
def
test_init
(
self
):
# No params
self
.
tests
.
append
(
test
.
MockingTest
())
# Positional
self
.
tests
.
append
(
test
.
MockingTest
(
"test"
,
test
.
TestID
(
1
,
"my_name"
),
def
test_init_positional
(
self
):
tst
=
test
.
MockingTest
(
"test"
,
test
.
TestID
(
1
,
"my_name"
),
{},
None
,
"1"
,
None
,
None
,
"extra_param1"
,
"extra_param2"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-my_name"
)
# Kwargs
self
.
tests
.
append
(
test
.
MockingTest
(
methodName
=
"test"
,
"extra_param2"
,
base_logdir
=
self
.
tmpdir
)
self
.
assertEqual
(
tst
.
name
,
"1-my_name"
)
def
test_init_kwargs
(
self
):
tst
=
test
.
MockingTest
(
methodName
=
"test"
,
name
=
test
.
TestID
(
1
,
"my_name2"
),
params
=
{},
base_logdir
=
None
,
params
=
{},
base_logdir
=
self
.
tmpdir
,
tag
=
"a"
,
job
=
None
,
runner_queue
=
None
,
extra1
=
"extra_param1"
,
extra2
=
"extra_param2"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-my_name2"
)
# both (theoretically impossible in python, but valid for nasty tests)
# keyword args are used as they explicitly represent what they mean
self
.
tests
.
append
(
test
.
MockingTest
(
"not used"
,
"who cares"
,
{},
None
,
"0"
,
extra2
=
"extra_param2"
)
self
.
assertEqual
(
tst
.
name
,
"1-my_name2"
)
def
test_positional_kwargs
(
self
):
"""
Tests both positional and kwargs (theoretically impossible in
python, but valid for nasty tests)
keyword args are used as they explicitly represent what they mean
"""
tst
=
test
.
MockingTest
(
"not used"
,
"who cares"
,
{},
None
,
"0"
,
None
,
None
,
"extra_param1"
,
"extra_param2"
,
methodName
=
"test"
,
name
=
test
.
TestID
(
1
,
"my_name3"
),
params
=
{},
base_logdir
=
None
,
params
=
{},
base_logdir
=
self
.
tmpdir
,
tag
=
"3"
,
job
=
None
,
runner_queue
=
None
,
extra1
=
"extra_param3"
,
extra2
=
"extra_param4"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-my_name3"
)
# combination
self
.
tests
.
append
(
test
.
MockingTest
(
"test"
,
test
.
TestID
(
1
,
"my_name4"
),
extra2
=
"extra_param4"
)
self
.
assertEqual
(
tst
.
name
,
"1-my_name3"
)
def
test_combination
(
self
):
tst
=
test
.
MockingTest
(
"test"
,
test
.
TestID
(
1
,
"my_name4"
),
tag
=
"321"
,
other_param
=
"Whatever"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-my_name4"
)
# ugly combination (positional argument overrides kwargs, this only
# happens when the substituted class reorders the positional arguments.
# We try to first match keyword args and then fall-back to positional
# ones.
other_param
=
"Whatever"
,
base_logdir
=
self
.
tmpdir
)
self
.
assertEqual
(
tst
.
name
,
"1-my_name4"
)
def
test_combination_2
(
self
):
"""
Tests an ugly combination (positional argument overrides
kwargs, this only happens when the substituted class reorders
the positional arguments. We try to first match keyword args
and then fall-back to positional ones.
"""
name
=
"positional_method_name_becomes_test_name"
tag
=
"positional_base_logdir_becomes_tag"
self
.
tests
.
append
(
test
.
MockingTest
(
test
.
TestID
(
1
,
name
),
None
,
None
,
tag
,
tst
=
test
.
MockingTest
(
test
.
TestID
(
1
,
name
),
None
,
None
,
tag
,
methodName
=
"test"
,
other_param
=
"Whatever"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-"
+
name
)
other_param
=
"Whatever"
,
base_logdir
=
self
.
tmpdir
)
self
.
assertEqual
(
tst
.
name
,
"1-"
+
name
)
def
tearDown
(
self
):
for
tst
in
self
.
tests
:
try
:
shutil
.
rmtree
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
tst
.
logdir
)))
except
Exception
:
pass
shutil
.
rmtree
(
self
.
tmpdir
)
class
TestID
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录