Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
bebda6eb
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,发现更多精彩内容 >>
未验证
提交
bebda6eb
编写于
8月 23, 2017
作者:
A
Amador Pahim
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'clebergnu-data_get_data_misc_fixes_only'
Signed-off-by:
N
Amador Pahim
<
apahim@redhat.com
>
上级
de7313b6
a67b2fb4
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
302 addition
and
209 deletion
+302
-209
avocado/core/data_dir.py
avocado/core/data_dir.py
+2
-6
avocado/core/runner.py
avocado/core/runner.py
+3
-3
avocado/core/test.py
avocado/core/test.py
+57
-43
avocado/utils/astring.py
avocado/utils/astring.py
+15
-10
docs/source/ReferenceGuide.rst
docs/source/ReferenceGuide.rst
+14
-8
docs/source/TestParameters.rst
docs/source/TestParameters.rst
+1
-1
docs/source/WritingTests.rst
docs/source/WritingTests.rst
+71
-71
optional_plugins/runner_remote/avocado_runner_remote/__init__.py
...l_plugins/runner_remote/avocado_runner_remote/__init__.py
+2
-2
selftests/unit/test_astring.py
selftests/unit/test_astring.py
+4
-4
selftests/unit/test_datadir.py
selftests/unit/test_datadir.py
+3
-3
selftests/unit/test_jsonresult.py
selftests/unit/test_jsonresult.py
+3
-3
selftests/unit/test_loader.py
selftests/unit/test_loader.py
+3
-3
selftests/unit/test_settings.py
selftests/unit/test_settings.py
+16
-16
selftests/unit/test_sysinfo.py
selftests/unit/test_sysinfo.py
+3
-3
selftests/unit/test_test.py
selftests/unit/test_test.py
+97
-25
selftests/unit/test_utils_asset.py
selftests/unit/test_utils_asset.py
+5
-5
selftests/unit/test_utils_output.py
selftests/unit/test_utils_output.py
+2
-2
selftests/unit/test_xunit.py
selftests/unit/test_xunit.py
+1
-1
未找到文件。
avocado/core/data_dir.py
浏览文件 @
bebda6eb
...
...
@@ -26,7 +26,6 @@ The general reasoning to find paths is:
* The next best location is the default user specific one.
"""
import
os
import
sys
import
shutil
import
time
import
tempfile
...
...
@@ -37,10 +36,6 @@ from .output import LOG_JOB
from
..utils
import
path
as
utils_path
from
..utils.data_structures
import
Borg
_BASE_DIR
=
os
.
path
.
join
(
sys
.
modules
[
__name__
].
__file__
,
".."
,
".."
,
".."
)
_BASE_DIR
=
os
.
path
.
abspath
(
_BASE_DIR
)
_IN_TREE_TESTS_DIR
=
os
.
path
.
join
(
_BASE_DIR
,
'examples'
,
'tests'
)
SYSTEM_BASE_DIR
=
'/var/lib/avocado'
if
'VIRTUAL_ENV'
in
os
.
environ
:
SYSTEM_BASE_DIR
=
os
.
environ
[
'VIRTUAL_ENV'
]
...
...
@@ -109,7 +104,8 @@ def get_test_dir():
return
configured
if
settings
.
settings
.
intree
:
return
_IN_TREE_TESTS_DIR
base_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)))
return
os
.
path
.
join
(
base_dir
,
'examples'
,
'tests'
)
if
utils_path
.
usable_ro_dir
(
SYSTEM_TEST_DIR
):
return
SYSTEM_TEST_DIR
...
...
avocado/core/runner.py
浏览文件 @
bebda6eb
...
...
@@ -580,9 +580,9 @@ class TestRunner(object):
index
+=
1
test_parameters
=
test_factory
[
1
]
name
=
test_parameters
.
get
(
"name"
)
test_parameters
[
"name"
]
=
test
.
Test
Name
(
index
+
1
,
name
,
variant
,
no_digits
)
test_parameters
[
"name"
]
=
test
.
Test
ID
(
index
+
1
,
name
,
variant
,
no_digits
)
if
deadline
is
not
None
and
time
.
time
()
>
deadline
:
summary
.
add
(
'INTERRUPTED'
)
if
'methodName'
in
test_parameters
:
...
...
avocado/core/test.py
浏览文件 @
bebda6eb
...
...
@@ -52,30 +52,24 @@ from .output import LOG_JOB
COMMON_TMPDIR_NAME
=
'AVOCADO_TESTS_COMMON_TMPDIR'
class
NameNotTestNameError
(
Exception
):
class
TestID
(
object
):
"""
T
he given test name is not a TestName instance
T
est ID construction and representation according to specification
With the introduction of :class:`avocado.core.test.TestName`, it's
not allowed to use other types as the ``name`` parameter to a test
instance. This exception is raised when this is attempted.
"""
class
TestName
(
object
):
"""
Test name representation
This class wraps the representation of both Avocado's Test ID
specification and Avocado's Test Name, which is part of a Test ID.
"""
def
__init__
(
self
,
uid
,
name
,
variant
=
None
,
no_digits
=
None
):
"""
Test name according to avocado specification
Constructs a TestID instance
:param uid: unique test id (within the job)
:param name: test name (identifies the executed test)
:param variant: variant id
:param name: test name, as returned by the Avocado test resolver
(AKA as test loader)
:param variant: the variant applied to this Test ID
:type variant: dict
:param no_digits: number of digits of the test uid
"""
self
.
uid
=
uid
...
...
@@ -84,12 +78,12 @@ class TestName(object):
else
:
self
.
str_uid
=
str
(
uid
)
self
.
name
=
name
or
"<unknown>"
self
.
variant
=
variant
[
"variant_id"
]
if
variant
else
None
if
variant
is
None
:
if
variant
is
None
or
variant
[
"variant_id"
]
is
None
:
self
.
variant
=
None
self
.
str_variant
=
""
else
:
self
.
str_variant
=
(
";"
+
str
(
variant
[
"variant_id"
])
if
variant
[
"variant_id"
]
else
""
)
self
.
variant
=
variant
[
"variant_id"
]
self
.
str_variant
=
";%s"
%
self
.
variant
def
__str__
(
self
):
return
"%s-%s%s"
%
(
self
.
str_uid
,
self
.
name
,
self
.
str_variant
)
...
...
@@ -103,26 +97,39 @@ class TestName(object):
else
:
return
self
.
__dict__
==
other
.
__dict__
@
property
def
str_filesystem
(
self
):
"""
File-system friendly representation of the test name
Test ID in a format suitable for use in file systems
The string returned should be safe to be used as a file or
directory name. This file system version of the test ID may
have to shorten either the Test Name or the Variant ID.
The first component of a Test ID, the numeric unique test id,
AKA "uid", will be used as a an stable identifier between the
Test ID and the file or directory created based on the return
value of this method. If the filesystem can not even
represent the "uid", than an exception will be raised.
For Test ID "001-mytest;foo", examples of shortened file
system versions include "001-mytest;f" or "001-myte;foo".
:raises: AssertionError
"""
name
=
str
(
self
)
fsname
=
astring
.
string_to_safe_path
(
name
)
if
len
(
name
)
==
len
(
fsname
):
# everything fits in
return
fsname
# 001-mytest;foo
# 001-mytest;f
# 001-myte;foo
idx_fit_variant
=
len
(
fsname
)
-
len
(
self
.
str_variant
)
test_id
=
str
(
self
)
test_id_fs
=
astring
.
string_to_safe_path
(
test_id
)
if
len
(
test_id
)
==
len
(
test_id_fs
):
# everything fits in
return
test_id_fs
idx_fit_variant
=
len
(
test_id_fs
)
-
len
(
self
.
str_variant
)
if
idx_fit_variant
>
len
(
self
.
str_uid
):
# full uid+variant
return
(
fsname
[:
idx_fit_variant
]
+
return
(
test_id_fs
[:
idx_fit_variant
]
+
astring
.
string_to_safe_path
(
self
.
str_variant
))
elif
len
(
self
.
str_uid
)
<=
len
(
fsname
):
# full uid
elif
len
(
self
.
str_uid
)
<=
len
(
test_id_fs
):
# full uid
return
astring
.
string_to_safe_path
(
self
.
str_uid
+
self
.
str_variant
)
else
:
# not even uid could be stored in fs
raise
AssertionError
(
"Test uid is too long to be stored on the "
"filesystem: %s
\n
Full test name is %s"
raise
AssertionError
(
'Test uid is too long to be stored on the '
'filesystem: "%s"
\n
Full Test ID: "%s"'
%
(
self
.
str_uid
,
str
(
self
)))
...
...
@@ -161,12 +168,11 @@ class Test(unittest.TestCase):
written with the avocado API, this should not be
set. This is reserved for internal Avocado use,
such as when running random executables as tests.
:type name: :class:`avocado.core.test.Test
Name
`
:type name: :class:`avocado.core.test.Test
ID
`
:param base_logdir: Directory where test logs should go. If None
provided, it'll use
:func:`avocado.data_dir.create_job_logs_dir`.
:param job: The job that this test is part of.
:raises: :class:`avocado.core.test.NameNotTestNameError`
"""
def
record_and_warn
(
*
args
,
**
kwargs
):
""" Record call to this function and log warning """
...
...
@@ -175,11 +181,9 @@ class Test(unittest.TestCase):
return
original_log_warn
(
*
args
,
**
kwargs
)
if
name
is
not
None
:
if
not
isinstance
(
name
,
TestName
):
raise
NameNotTestNameError
(
name
)
self
.
__name
=
name
else
:
self
.
__name
=
Test
Name
(
0
,
self
.
__class__
.
__name__
)
self
.
__name
=
Test
ID
(
0
,
self
.
__class__
.
__name__
)
self
.
__job
=
job
...
...
@@ -195,7 +199,7 @@ class Test(unittest.TestCase):
if
base_logdir
is
None
:
base_logdir
=
data_dir
.
create_job_logs_dir
()
base_logdir
=
os
.
path
.
join
(
base_logdir
,
'test-results'
)
logdir
=
os
.
path
.
join
(
base_logdir
,
self
.
name
.
str_filesystem
()
)
logdir
=
os
.
path
.
join
(
base_logdir
,
self
.
name
.
str_filesystem
)
if
os
.
path
.
exists
(
logdir
):
raise
exceptions
.
TestSetupFail
(
"Log dir already exists, this "
"should never happen: %s"
...
...
@@ -262,7 +266,9 @@ class Test(unittest.TestCase):
@
property
def
name
(
self
):
"""
The test name (TestName instance)
Returns the Test ID, which includes the test name
:rtype: TestID
"""
return
self
.
__name
...
...
@@ -321,7 +327,15 @@ class Test(unittest.TestCase):
@
property
def
datadir
(
self
):
"""
Returns the path to the directory that contains test data files
Returns the path to the directory that may contain test data files
For test a test file hosted at /usr/share/avocado/tests/sleeptest.py
the datadir is /usr/share/avocado/tests/sleeptest.py.data.
Note that this directory has no specific relation to the test
name, only to the file that contains the test. It can be used to
host data files that are generic enough to be used for all tests
contained in a given test file.
"""
# Maximal allowed file name length is 255
if
(
self
.
filename
is
not
None
and
...
...
@@ -865,7 +879,7 @@ class SimpleTest(Test):
self
.
log
.
info
(
"Exit status: %s"
,
result
.
exit_status
)
self
.
log
.
info
(
"Duration: %s"
,
result
.
duration
)
def
execute_cmd
(
self
):
def
_
execute_cmd
(
self
):
"""
Run the executable, and log its detailed execution.
"""
...
...
@@ -891,7 +905,7 @@ class SimpleTest(Test):
"""
Run the test and postprocess the results
"""
self
.
execute_cmd
()
self
.
_
execute_cmd
()
class
ExternalRunnerTest
(
SimpleTest
):
...
...
@@ -929,7 +943,7 @@ class ExternalRunnerTest(SimpleTest):
new_cwd
)
os
.
chdir
(
new_cwd
)
self
.
execute_cmd
()
self
.
_
execute_cmd
()
finally
:
if
new_cwd
is
not
None
:
...
...
avocado/utils/astring.py
浏览文件 @
bebda6eb
...
...
@@ -209,25 +209,30 @@ def tabular_output(matrix, header=None):
return
"
\n
"
.
join
(
iter_tabular_output
(
matrix
,
header
))
def
string_safe_encode
(
string
):
def
string_safe_encode
(
input_str
):
"""
People tend to mix unicode streams with encoded strings. This function
tries to replace any input with a valid utf-8 encoded ascii stream.
:param input_str: possibly unsafe string or other object that can
be turned into a string
:returns: a utf-8 encoded ascii stream
"""
if
not
isinstance
(
string
,
basestring
):
string
=
str
(
string
)
if
not
isinstance
(
input_str
,
basestring
):
input_str
=
str
(
input_str
)
try
:
return
string
.
encode
(
"utf-8"
)
return
input_str
.
encode
(
"utf-8"
)
except
UnicodeDecodeError
:
return
string
.
decode
(
"utf-8"
,
"replace"
).
encode
(
"utf-8"
)
return
input_str
.
decode
(
"utf-8"
,
"replace"
).
encode
(
"utf-8"
)
def
string_to_safe_path
(
string
):
def
string_to_safe_path
(
input_str
):
"""
Convert string to a valid file/dir name.
:param string: String to be converted
:param input_str: String to be converted
:return: String which is safe to pass as a file/dir name (on recent fs)
"""
if
string
.
startswith
(
"."
):
string
=
"_"
+
string
[
1
:]
return
string
.
replace
(
os
.
path
.
sep
,
'_'
)[:
255
]
if
input_str
.
startswith
(
"."
):
input_str
=
"_"
+
input_str
[
1
:]
return
input_str
.
replace
(
os
.
path
.
sep
,
'_'
)[:
255
]
docs/source/ReferenceGuide.rst
浏览文件 @
bebda6eb
...
...
@@ -66,6 +66,14 @@ By definition, a Test Name is a Test Reference, but the
reciprocal is not necessarily true, as the latter can represent
more than one test.
Examples of Test Names::
'/bin/true'
'passtest.py:Passtest.test'
'file:///tmp/passtest.py:Passtest.test'
'multiple_tests.py:MultipleTests.test_hello'
'type_specific.io-github-autotest-qemu.systemtap_tracing.qemu.qemu_free'
Variant IDs
-----------
...
...
@@ -108,15 +116,13 @@ Syntax::
<unique-id>-<test-name>[;<variant-id>]
Examples of test-names::
'/bin/true'
'/bin/grep foobar /etc/passwd'
'passtest.py:Passtest.test'
'file:///tmp/passtest.py:Passtest.test'
'multiple_tests.py:MultipleTests.test_hello'
'type_specific.io-github-autotest-qemu.systemtap_tracing.qemu.qemu_free'
Example of Test IDs::
'1-/bin/true'
'2-passtest.py:Passtest.test;quiet-'
'3-file:///tmp/passtest.py:Passtest.test'
'4-multiple_tests.py:MultipleTests.test_hello;maximum_debug-df2f'
'5-type_specific.io-github-autotest-qemu.systemtap_tracing.qemu.qemu_free'
.. _test-types:
...
...
docs/source/TestParameters.rst
浏览文件 @
bebda6eb
...
...
@@ -102,7 +102,7 @@ AvocadoParams
Is a "database" of params present in every (instrumented) avocado test.
It's produced during :class:`avocado.core.test.Test`'s ``__init__``
from a `variant`_. It accepts a list of `TreeNode`_ objects; test name
:class:`avocado.core.test.Test
Name
` (for logging purposes); list of
:class:`avocado.core.test.Test
ID
` (for logging purposes); list of
default paths (`Mux path`_) and the `Test's default params`_.
In test it allows querying for data by using::
...
...
docs/source/WritingTests.rst
浏览文件 @
bebda6eb
...
...
@@ -266,69 +266,69 @@ as an example:
Which produces following structure and parameters::
$ avocado variants -m examples/tests/sleeptenmin.py.data/sleeptenmin.yaml --summary 2 --variants 2
Multiplex tree representation:
┗━━ run
┣━━ sleeptenmin
┃ ╠══ builtin
┃ ║ → sleep_method: builtin
┃ ╚══ shell
┃ → sleep_method: shell
┗━━ variants
╠══ one_cycle
║ → sleep_length: 600
║ → sleep_cycles: 1
╠══ six_cycles
║ → sleep_length: 100
║ → sleep_cycles: 6
╠══ one_hundred_cycles
║ → sleep_length: 6
║ → sleep_cycles: 100
╚══ six_hundred_cycles
→ sleep_length: 1
→ sleep_cycles: 600
Multiplex variants
:
Variant 1
: /run/sleeptenmin/builtin, /run/variants/one_cycle
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/one_cycle:sleep_cycles => 1
/run/variants/one_cycle:sleep_length => 600
Variant 2
: /run/sleeptenmin/builtin, /run/variants/six_cycles
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/six_cycles:sleep_cycles => 6
/run/variants/six_cycles:sleep_length => 100
Variant 3
: /run/sleeptenmin/builtin, /run/variants/one_hundred_cycles
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/one_hundred_cycles:sleep_cycles => 100
/run/variants/one_hundred_cycles:sleep_length => 6
Variant 4
: /run/sleeptenmin/builtin, /run/variants/six_hundred_cycles
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/six_hundred_cycles:sleep_cycles => 600
/run/variants/six_hundred_cycles:sleep_length => 1
Variant
5: /run/sleeptenmin/shell, /run/variants/one_cycle
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/one_cycle:sleep_cycles => 1
/run/variants/one_cycle:sleep_length => 600
Variant 6
: /run/sleeptenmin/shell, /run/variants/six_cycles
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/six_cycles:sleep_cycles => 6
/run/variants/six_cycles:sleep_length => 100
Variant 7
: /run/sleeptenmin/shell, /run/variants/one_hundred_cycles
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/one_hundred_cycles:sleep_cycles => 100
/run/variants/one_hundred_cycles:sleep_length => 6
Variant 8
: /run/sleeptenmin/shell, /run/variants/six_hundred_cycles
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/six_hundred_cycles:sleep_cycles => 600
/run/variants/six_hundred_cycles:sleep_length => 1
$ avocado variants -m examples/tests/sleeptenmin.py.data/sleeptenmin.yaml --summary 2 --variants 2
Multiplex tree representation:
┗━━ run
┣━━ sleeptenmin
┃ ╠══ builtin
┃ ║ → sleep_method: builtin
┃ ╚══ shell
┃ → sleep_method: shell
┗━━ variants
╠══ one_cycle
║ → sleep_length: 600
║ → sleep_cycles: 1
╠══ six_cycles
║ → sleep_length: 100
║ → sleep_cycles: 6
╠══ one_hundred_cycles
║ → sleep_length: 6
║ → sleep_cycles: 100
╚══ six_hundred_cycles
→ sleep_length: 1
→ sleep_cycles: 600
Multiplex variants (8)
:
Variant builtin-one_cycle-f659
: /run/sleeptenmin/builtin, /run/variants/one_cycle
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/one_cycle:sleep_cycles => 1
/run/variants/one_cycle:sleep_length => 600
Variant builtin-six_cycles-723b
: /run/sleeptenmin/builtin, /run/variants/six_cycles
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/six_cycles:sleep_cycles => 6
/run/variants/six_cycles:sleep_length => 100
Variant builtin-one_hundred_cycles-633a
: /run/sleeptenmin/builtin, /run/variants/one_hundred_cycles
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/one_hundred_cycles:sleep_cycles => 100
/run/variants/one_hundred_cycles:sleep_length => 6
Variant builtin-six_hundred_cycles-a570
: /run/sleeptenmin/builtin, /run/variants/six_hundred_cycles
/run/sleeptenmin/builtin:sleep_method => builtin
/run/variants/six_hundred_cycles:sleep_cycles => 600
/run/variants/six_hundred_cycles:sleep_length => 1
Variant shell-one_cycle-55f
5: /run/sleeptenmin/shell, /run/variants/one_cycle
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/one_cycle:sleep_cycles => 1
/run/variants/one_cycle:sleep_length => 600
Variant shell-six_cycles-9e23
: /run/sleeptenmin/shell, /run/variants/six_cycles
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/six_cycles:sleep_cycles => 6
/run/variants/six_cycles:sleep_length => 100
Variant shell-one_hundred_cycles-586f
: /run/sleeptenmin/shell, /run/variants/one_hundred_cycles
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/one_hundred_cycles:sleep_cycles => 100
/run/variants/one_hundred_cycles:sleep_length => 6
Variant shell-six_hundred_cycles-1e84
: /run/sleeptenmin/shell, /run/variants/six_hundred_cycles
/run/sleeptenmin/shell:sleep_method => shell
/run/variants/six_hundred_cycles:sleep_cycles => 600
/run/variants/six_hundred_cycles:sleep_length => 1
You can see that it creates all possible variants of each ``multiplex domain``,
which are defined by ``!mux`` tag in the YAML file and displayed as single
...
...
@@ -338,14 +338,14 @@ values). In total it'll produce 8 variants of each test::
$ avocado run --mux-yaml examples/tests/sleeptenmin.py.data/sleeptenmin.yaml -- passtest.py
JOB ID : cc7ef22654c683b73174af6f97bc385da5a0f02f
JOB LOG : /home/medic/avocado/job-results/job-2017-01-22T11.26-cc7ef22/job.log
(1/8) passtest.py:PassTest.test;
1
: PASS (0.01 s)
(2/8) passtest.py:PassTest.test;
2
: PASS (0.01 s)
(3/8) passtest.py:PassTest.test;
3
: PASS (0.01 s)
(4/8) passtest.py:PassTest.test;
4
: PASS (0.01 s)
(5/8) passtest.py:PassTest.test;5: PASS (0.01 s)
(6/8) passtest.py:PassTest.test;
6
: PASS (0.01 s)
(7/8) passtest.py:PassTest.test;
7
: PASS (0.01 s)
(8/8) passtest.py:PassTest.test;
8
: PASS (0.01 s)
(1/8) passtest.py:PassTest.test;
builtin-one_cycle-f659
: PASS (0.01 s)
(2/8) passtest.py:PassTest.test;
builtin-six_cycles-723b
: PASS (0.01 s)
(3/8) passtest.py:PassTest.test;
builtin-one_hundred_cycles-633a
: PASS (0.01 s)
(4/8) passtest.py:PassTest.test;
builtin-six_hundred_cycles-a570
: PASS (0.01 s)
(5/8) passtest.py:PassTest.test;
shell-one_cycle-55f
5: PASS (0.01 s)
(6/8) passtest.py:PassTest.test;
shell-six_cycles-9e23
: PASS (0.01 s)
(7/8) passtest.py:PassTest.test;
shell-one_hundred_cycles-586f
: PASS (0.01 s)
(8/8) passtest.py:PassTest.test;
shell-six_hundred_cycles-1e84
: PASS (0.01 s)
RESULTS : PASS 8 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0
JOB TIME : 0.16 s
...
...
optional_plugins/runner_remote/avocado_runner_remote/__init__.py
浏览文件 @
bebda6eb
...
...
@@ -37,7 +37,7 @@ from avocado.core.output import LOG_JOB, LOG_UI
from
avocado.core.plugin_interfaces
import
CLI
from
avocado.core.runner
import
TestRunner
from
avocado.core.settings
import
settings
from
avocado.core.test
import
Test
Name
from
avocado.core.test
import
Test
ID
from
avocado.utils
import
archive
from
avocado.utils
import
astring
from
avocado.utils
import
process
...
...
@@ -507,7 +507,7 @@ class RemoteTestRunner(TestRunner):
name
=
[
name
[
0
]]
+
name
[
1
].
split
(
';'
)
if
len
(
name
)
==
3
:
name
[
2
]
=
{
"variant_id"
:
name
[
2
]}
name
=
Test
Name
(
*
name
,
no_digits
=-
1
)
name
=
Test
ID
(
*
name
,
no_digits
=-
1
)
state
=
dict
(
name
=
name
,
time_elapsed
=
tst
[
'time'
],
time_start
=
tst
[
'start'
],
...
...
selftests/unit/test_astring.py
浏览文件 @
bebda6eb
...
...
@@ -5,7 +5,7 @@ from avocado.utils import astring
class
AstringTest
(
unittest
.
TestCase
):
def
test
TabularO
utput
(
self
):
def
test
_tabular_o
utput
(
self
):
matrix
=
[(
'foo'
,
'bar'
),
(
'/bin/bar/sbrubles'
,
'/home/myuser/sbrubles'
)]
self
.
assertEqual
(
astring
.
tabular_output
(
matrix
),
...
...
@@ -17,7 +17,7 @@ class AstringTest(unittest.TestCase):
'foo bar
\n
'
'/bin/bar/sbrubles /home/myuser/sbrubles'
))
def
test
TabularWithConsoleC
odes
(
self
):
def
test
_tabular_with_console_c
odes
(
self
):
matrix
=
[(
"a"
,
"an"
,
"dog"
,
"word"
,
"last"
),
(
"
\x1b
[94ma"
,
# {BLUE}a
"
\033
[0man"
,
# {END}an
...
...
@@ -32,7 +32,7 @@ class AstringTest(unittest.TestCase):
"[94ma [0man cc[91mc "
"[91md[92md[94md[90md[0m last"
)
def
test
TabularOutputDifferentNOC
ols
(
self
):
def
test
_tabular_output_different_no_c
ols
(
self
):
matrix
=
[[],
[
1
],
[
2
,
2
],
[
333
,
333
,
333
],
[
4
,
4
,
4
,
4444
]]
self
.
assertEqual
(
astring
.
tabular_output
(
matrix
),
"1
\n
"
...
...
@@ -40,7 +40,7 @@ class AstringTest(unittest.TestCase):
"333 333 333
\n
"
"4 4 4 4444"
)
def
test
UnicodeT
abular
(
self
):
def
test
_unicode_t
abular
(
self
):
"""
Verifies tabular can handle utf-8 chars properly
...
...
selftests/unit/test_datadir.py
浏览文件 @
bebda6eb
...
...
@@ -37,7 +37,7 @@ class DataDirTest(unittest.TestCase):
(
self
.
mapping
,
self
.
config_file_path
)
=
self
.
_get_temporary_dirs_mapping_and_config
()
def
test
DataDirFromC
onfig
(
self
):
def
test
_datadir_from_c
onfig
(
self
):
"""
When avocado.conf is present, honor the values coming from it.
"""
...
...
@@ -57,7 +57,7 @@ class DataDirTest(unittest.TestCase):
flexmock
(
settings
,
settings
=
stg_orig
)
del
data_dir
def
test
UniqueLogD
ir
(
self
):
def
test
_unique_log_d
ir
(
self
):
"""
Tests that multiple queries for a logdir at the same time provides
unique results.
...
...
@@ -78,7 +78,7 @@ class DataDirTest(unittest.TestCase):
self
.
assertEqual
(
path
,
path_prefix
+
uid
+
".1"
)
self
.
assertTrue
(
os
.
path
.
exists
(
path
))
def
test
SettingsDirAlternateD
ynamic
(
self
):
def
test
_settings_dir_alternate_d
ynamic
(
self
):
"""
Tests that changes to the data_dir settings are applied dynamically
...
...
selftests/unit/test_jsonresult.py
浏览文件 @
bebda6eb
...
...
@@ -44,7 +44,7 @@ class JSONResultTest(unittest.TestCase):
os
.
remove
(
self
.
tmpfile
[
1
])
shutil
.
rmtree
(
self
.
tmpdir
)
def
test
AddS
uccess
(
self
):
def
test
_add_s
uccess
(
self
):
self
.
test_result
.
start_test
(
self
.
test1
)
self
.
test_result
.
end_test
(
self
.
test1
.
get_state
())
self
.
test_result
.
end_tests
()
...
...
@@ -56,7 +56,7 @@ class JSONResultTest(unittest.TestCase):
self
.
assertTrue
(
obj
)
self
.
assertEqual
(
len
(
obj
[
'tests'
]),
1
)
def
test
AddSeveralS
tatuses
(
self
):
def
test
_add_several_s
tatuses
(
self
):
def
run_fake_status
(
status
):
self
.
test_result
.
start_test
(
self
.
test1
)
self
.
test_result
.
check_test
(
status
)
...
...
@@ -92,7 +92,7 @@ class JSONResultTest(unittest.TestCase):
check_item
(
"[skip]"
,
res
[
"skip"
],
4
)
check_item
(
"[total]"
,
res
[
"total"
],
13
)
def
test
NegativeS
tatus
(
self
):
def
test
_negative_s
tatus
(
self
):
def
check_item
(
name
,
value
,
exp
):
self
.
assertEqual
(
value
,
exp
,
"Result%s is %s and not %s
\n
%s"
%
(
name
,
value
,
exp
,
res
))
...
...
selftests/unit/test_loader.py
浏览文件 @
bebda6eb
...
...
@@ -253,7 +253,7 @@ class LoaderTest(unittest.TestCase):
test_class
,
test_parameters
=
(
self
.
loader
.
discover
(
simple_test
.
path
,
loader
.
ALL
)[
0
])
self
.
assertTrue
(
test_class
==
test
.
SimpleTest
,
test_class
)
test_parameters
[
'name'
]
=
test
.
Test
Name
(
0
,
test_parameters
[
'name'
])
test_parameters
[
'name'
]
=
test
.
Test
ID
(
0
,
test_parameters
[
'name'
])
test_parameters
[
'base_logdir'
]
=
self
.
tmpdir
tc
=
test_class
(
**
test_parameters
)
tc
.
run_avocado
()
...
...
@@ -299,7 +299,7 @@ class LoaderTest(unittest.TestCase):
test_class
,
test_parameters
=
(
self
.
loader
.
discover
(
avocado_not_a_test
.
path
,
loader
.
ALL
)[
0
])
self
.
assertTrue
(
test_class
==
test
.
SimpleTest
,
test_class
)
test_parameters
[
'name'
]
=
test
.
Test
Name
(
0
,
test_parameters
[
'name'
])
test_parameters
[
'name'
]
=
test
.
Test
ID
(
0
,
test_parameters
[
'name'
])
test_parameters
[
'base_logdir'
]
=
self
.
tmpdir
tc
=
test_class
(
**
test_parameters
)
# The test can't be executed (no shebang), raising an OSError
...
...
@@ -315,7 +315,7 @@ class LoaderTest(unittest.TestCase):
test_class
,
test_parameters
=
(
self
.
loader
.
discover
(
avocado_simple_test
.
path
,
loader
.
ALL
)[
0
])
self
.
assertTrue
(
test_class
==
test
.
SimpleTest
)
test_parameters
[
'name'
]
=
test
.
Test
Name
(
0
,
test_parameters
[
'name'
])
test_parameters
[
'name'
]
=
test
.
Test
ID
(
0
,
test_parameters
[
'name'
])
test_parameters
[
'base_logdir'
]
=
self
.
tmpdir
tc
=
test_class
(
**
test_parameters
)
tc
.
run_avocado
()
...
...
selftests/unit/test_settings.py
浏览文件 @
bebda6eb
...
...
@@ -24,21 +24,21 @@ class SettingsTest(unittest.TestCase):
self
.
config_file
.
close
()
self
.
settings
=
settings
.
Settings
(
self
.
config_file
.
name
)
def
test
StringC
onversion
(
self
):
def
test
_string_c
onversion
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'str_key'
,
str
),
'frobnicate'
)
def
test
IntC
onversion
(
self
):
def
test
_int_c
onversion
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'int_key'
,
int
),
1
)
def
test
FloatC
onversion
(
self
):
def
test
_float_c
onversion
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'float_key'
,
float
),
1.25
)
def
test
BoolC
onversion
(
self
):
def
test
_bool_c
onversion
(
self
):
self
.
assertTrue
(
self
.
settings
.
get_value
(
'foo'
,
'bool_key'
,
bool
))
def
test
PathHomeD
ir
(
self
):
def
test
_path_homed
ir
(
self
):
raw_from_settings
=
'~/path/at/home'
path_from_settings
=
self
.
settings
.
get_value
(
'foo'
,
'path'
,
'path'
)
home_str_from_settings
=
self
.
settings
.
get_value
(
'foo'
,
'home_path'
,
str
)
...
...
@@ -49,47 +49,47 @@ class SettingsTest(unittest.TestCase):
self
.
assertEqual
(
os
.
path
.
expanduser
(
home_str_from_settings
),
self
.
settings
.
get_value
(
'foo'
,
'home_path'
,
'path'
))
def
test
PathOnStrK
ey
(
self
):
def
test
_path_on_str_k
ey
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'path'
,
str
),
'~/path/at/home'
)
def
test
ListC
onversion
(
self
):
def
test
_list_c
onversion
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'list_key'
,
list
),
[
'I'
,
'love'
,
'settings'
])
def
test
D
efault
(
self
):
def
test
_d
efault
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'non_existing'
,
str
,
"ohnoes"
),
"ohnoes"
)
def
test
NonExistingK
ey
(
self
):
def
test
_non_existing_k
ey
(
self
):
with
self
.
assertRaises
(
settings
.
SettingsError
):
self
.
settings
.
get_value
(
'foo'
,
'non_existing'
,
str
)
def
test
AllowBlankTrueS
tr
(
self
):
def
test
_allow_blank_true_s
tr
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
str
,
allow_blank
=
True
),
""
)
def
test
AllowBlankTrueI
nt
(
self
):
def
test
_allow_blank_true_i
nt
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
int
,
allow_blank
=
True
),
0
)
def
test
AllowBlankTrueF
loat
(
self
):
def
test
_allow_blank_true_f
loat
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
float
,
allow_blank
=
True
),
0.0
)
def
test
AllowBlankTrueL
ist
(
self
):
def
test
_allow_blank_true_l
ist
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
list
,
allow_blank
=
True
),
[])
def
test
AllowBlankTrueB
ool
(
self
):
def
test
_allow_blank_true_b
ool
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
bool
,
allow_blank
=
True
),
False
)
def
test
AllowBlankTrueO
ther
(
self
):
def
test
_allow_blank_true_o
ther
(
self
):
self
.
assertEqual
(
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
'baz'
,
allow_blank
=
True
),
None
)
def
test
AllowBlankF
alse
(
self
):
def
test
_allow_blank_f
alse
(
self
):
with
self
.
assertRaises
(
settings
.
SettingsError
):
self
.
settings
.
get_value
(
'foo'
,
'empty_key'
,
str
)
...
...
selftests/unit/test_sysinfo.py
浏览文件 @
bebda6eb
...
...
@@ -11,7 +11,7 @@ class SysinfoTest(unittest.TestCase):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
"sysinfo_unittest"
)
def
test
LoggablesE
qual
(
self
):
def
test
_loggables_e
qual
(
self
):
cmd1
=
sysinfo
.
Command
(
"ls -l"
)
cmd2
=
sysinfo
.
Command
(
"ls -l"
)
self
.
assertEqual
(
cmd1
,
cmd2
)
...
...
@@ -19,7 +19,7 @@ class SysinfoTest(unittest.TestCase):
file2
=
sysinfo
.
Logfile
(
"/proc/cpuinfo"
)
self
.
assertEqual
(
file1
,
file2
)
def
test
LoggablesNotE
qual
(
self
):
def
test
_loggables_not_e
qual
(
self
):
cmd1
=
sysinfo
.
Command
(
"ls -l"
)
cmd2
=
sysinfo
.
Command
(
"ls -la"
)
self
.
assertNotEqual
(
cmd1
,
cmd2
)
...
...
@@ -27,7 +27,7 @@ class SysinfoTest(unittest.TestCase):
file2
=
sysinfo
.
Logfile
(
"/etc/fstab"
)
self
.
assertNotEqual
(
file1
,
file2
)
def
test
LoggablesS
et
(
self
):
def
test
_loggables_s
et
(
self
):
container
=
set
()
cmd1
=
sysinfo
.
Command
(
"ls -l"
)
cmd2
=
sysinfo
.
Command
(
"ls -l"
)
...
...
selftests/unit/test_test.py
浏览文件 @
bebda6eb
...
...
@@ -30,10 +30,10 @@ class TestClassTestUnit(unittest.TestCase):
flexmock_teardown
()
shutil
.
rmtree
(
self
.
tmpdir
)
def
test
UglyN
ame
(
self
):
def
test
_ugly_n
ame
(
self
):
def
run
(
name
,
path_name
):
""" Initialize test and check the dirs were created """
tst
=
self
.
DummyTest
(
"test"
,
test
.
Test
Name
(
1
,
name
),
tst
=
self
.
DummyTest
(
"test"
,
test
.
Test
ID
(
1
,
name
),
base_logdir
=
self
.
tmpdir
)
self
.
assertEqual
(
os
.
path
.
basename
(
tst
.
logdir
),
path_name
)
self
.
assertTrue
(
os
.
path
.
exists
(
tst
.
logdir
))
...
...
@@ -56,9 +56,9 @@ class TestClassTestUnit(unittest.TestCase):
"
\xac\xef\xb7\xad\xef\xb7\xae\xef\xb7\xaf
"
)
run
(
name
,
"1-"
+
name
)
def
test
LongN
ame
(
self
):
def
test
_long_n
ame
(
self
):
def
check
(
uid
,
name
,
variant
,
exp_logdir
):
tst
=
self
.
DummyTest
(
"test"
,
test
.
Test
Name
(
uid
,
name
,
variant
),
tst
=
self
.
DummyTest
(
"test"
,
test
.
Test
ID
(
uid
,
name
,
variant
),
base_logdir
=
self
.
tmpdir
)
self
.
assertEqual
(
os
.
path
.
basename
(
tst
.
logdir
),
exp_logdir
)
return
tst
...
...
@@ -93,13 +93,13 @@ class TestClassTestUnit(unittest.TestCase):
tst
.
_record_reference_stdout
()
tst
.
_record_reference_stderr
()
def
test
AllDirsExistsNoH
ang
(
self
):
def
test
_all_dirs_exists_no_h
ang
(
self
):
flexmock
(
os
.
path
)
os
.
path
.
should_receive
(
'exists'
).
and_return
(
True
)
self
.
assertRaises
(
exceptions
.
TestSetupFail
,
self
.
DummyTest
,
"test"
,
test
.
Test
Name
(
1
,
"name"
),
base_logdir
=
self
.
tmpdir
)
test
.
Test
ID
(
1
,
"name"
),
base_logdir
=
self
.
tmpdir
)
def
test
TryOverrideTestV
ariable
(
self
):
def
test
_try_override_test_v
ariable
(
self
):
test
=
self
.
DummyTest
(
base_logdir
=
self
.
tmpdir
)
self
.
assertRaises
(
AttributeError
,
setattr
,
test
,
"name"
,
"whatever"
)
self
.
assertRaises
(
AttributeError
,
setattr
,
test
,
"status"
,
"whatever"
)
...
...
@@ -119,16 +119,16 @@ class TestClassTest(unittest.TestCase):
self
.
tst_instance_pass
=
AvocadoPass
(
base_logdir
=
self
.
base_logdir
)
self
.
tst_instance_pass
.
run_avocado
()
def
test
ClassAttributesN
ame
(
self
):
def
test
_class_attributes_n
ame
(
self
):
self
.
assertEqual
(
self
.
tst_instance_pass
.
name
,
'0-AvocadoPass'
)
def
test
ClassAttributesS
tatus
(
self
):
def
test
_class_attributes_s
tatus
(
self
):
self
.
assertEqual
(
self
.
tst_instance_pass
.
status
,
'PASS'
)
def
test
ClassAttributesTimeE
lapsed
(
self
):
def
test
_class_attributes_time_e
lapsed
(
self
):
self
.
assertIsInstance
(
self
.
tst_instance_pass
.
time_elapsed
,
float
)
def
test
WhiteboardS
ave
(
self
):
def
test
_whiteboard_s
ave
(
self
):
whiteboard_file
=
os
.
path
.
join
(
self
.
tst_instance_pass
.
logdir
,
'whiteboard'
)
self
.
assertTrue
(
os
.
path
.
isfile
(
whiteboard_file
))
...
...
@@ -136,7 +136,7 @@ class TestClassTest(unittest.TestCase):
whiteboard_contents
=
whiteboard_file_obj
.
read
().
strip
()
self
.
assertTrue
(
whiteboard_contents
,
'foo'
)
def
test
RunningTestTwiceWithTheSameUidF
ailure
(
self
):
def
test
_running_test_twice_with_the_same_uid_f
ailure
(
self
):
class
AvocadoPass
(
test
.
Test
):
def
test
(
self
):
...
...
@@ -145,10 +145,6 @@ class TestClassTest(unittest.TestCase):
self
.
assertRaises
(
exceptions
.
TestSetupFail
,
AvocadoPass
,
base_logdir
=
self
.
base_logdir
)
def
testNotTestName
(
self
):
self
.
assertRaises
(
test
.
NameNotTestNameError
,
test
.
Test
,
name
=
'mytest'
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
base_logdir
)
...
...
@@ -170,19 +166,19 @@ class SimpleTestClassTest(unittest.TestCase):
self
.
fail_script
.
save
()
self
.
tst_instance_pass
=
test
.
SimpleTest
(
name
=
test
.
Test
Name
(
1
,
self
.
pass_script
.
path
),
name
=
test
.
Test
ID
(
1
,
self
.
pass_script
.
path
),
base_logdir
=
self
.
tmpdir
)
self
.
tst_instance_pass
.
run_avocado
()
self
.
tst_instance_fail
=
test
.
SimpleTest
(
name
=
test
.
Test
Name
(
1
,
self
.
fail_script
.
path
),
name
=
test
.
Test
ID
(
1
,
self
.
fail_script
.
path
),
base_logdir
=
self
.
tmpdir
)
self
.
tst_instance_fail
.
run_avocado
()
def
test
SimpleTestPassS
tatus
(
self
):
def
test
_simple_test_pass_s
tatus
(
self
):
self
.
assertEqual
(
self
.
tst_instance_pass
.
status
,
'PASS'
)
def
test
SimpleTestFailS
tatus
(
self
):
def
test
_simple_test_fail_s
tatus
(
self
):
self
.
assertEqual
(
self
.
tst_instance_fail
.
status
,
'FAIL'
)
def
tearDown
(
self
):
...
...
@@ -200,14 +196,14 @@ class MockingTest(unittest.TestCase):
# No params
self
.
tests
.
append
(
test
.
MockingTest
())
# Positional
self
.
tests
.
append
(
test
.
MockingTest
(
"test"
,
test
.
Test
Name
(
1
,
"my_name"
),
self
.
tests
.
append
(
test
.
MockingTest
(
"test"
,
test
.
Test
ID
(
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"
,
name
=
test
.
Test
Name
(
1
,
"my_name2"
),
name
=
test
.
Test
ID
(
1
,
"my_name2"
),
params
=
{},
base_logdir
=
None
,
tag
=
"a"
,
job
=
None
,
runner_queue
=
None
,
extra1
=
"extra_param1"
,
...
...
@@ -219,14 +215,14 @@ class MockingTest(unittest.TestCase):
None
,
None
,
"extra_param1"
,
"extra_param2"
,
methodName
=
"test"
,
name
=
test
.
Test
Name
(
1
,
"my_name3"
),
name
=
test
.
Test
ID
(
1
,
"my_name3"
),
params
=
{},
base_logdir
=
None
,
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
.
Test
Name
(
1
,
"my_name4"
),
self
.
tests
.
append
(
test
.
MockingTest
(
"test"
,
test
.
Test
ID
(
1
,
"my_name4"
),
tag
=
"321"
,
other_param
=
"Whatever"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-my_name4"
)
...
...
@@ -236,7 +232,7 @@ class MockingTest(unittest.TestCase):
# ones.
name
=
"positional_method_name_becomes_test_name"
tag
=
"positional_base_logdir_becomes_tag"
self
.
tests
.
append
(
test
.
MockingTest
(
test
.
Test
Name
(
1
,
name
),
None
,
None
,
tag
,
self
.
tests
.
append
(
test
.
MockingTest
(
test
.
Test
ID
(
1
,
name
),
None
,
None
,
tag
,
methodName
=
"test"
,
other_param
=
"Whatever"
))
self
.
assertEqual
(
self
.
tests
[
-
1
].
name
,
"1-"
+
name
)
...
...
@@ -249,5 +245,81 @@ class MockingTest(unittest.TestCase):
pass
class
TestID
(
unittest
.
TestCase
):
def
test_uid_name
(
self
):
uid
=
1
name
=
'file.py:klass.test_method'
test_id
=
test
.
TestID
(
uid
,
name
)
self
.
assertEqual
(
test_id
.
uid
,
1
)
self
.
assertEqual
(
test_id
.
str_uid
,
'1'
)
self
.
assertEqual
(
test_id
.
str_filesystem
,
'%s-%s'
%
(
uid
,
name
))
self
.
assertIs
(
test_id
.
variant
,
None
)
self
.
assertIs
(
test_id
.
str_variant
,
''
)
def
test_uid_name_no_digits
(
self
):
uid
=
1
name
=
'file.py:klass.test_method'
test_id
=
test
.
TestID
(
uid
,
name
,
no_digits
=
2
)
self
.
assertEqual
(
test_id
.
uid
,
1
)
self
.
assertEqual
(
test_id
.
str_uid
,
'01'
)
self
.
assertEqual
(
test_id
.
str_filesystem
,
'%s-%s'
%
(
'01'
,
name
))
self
.
assertIs
(
test_id
.
variant
,
None
)
self
.
assertIs
(
test_id
.
str_variant
,
''
)
def
test_uid_name_large_digits
(
self
):
"""
Tests that when the filesystem can only cope with the size of
the Test ID, that's the only thing that will be kept.
"""
uid
=
1
name
=
'test'
test_id
=
test
.
TestID
(
uid
,
name
,
no_digits
=
255
)
self
.
assertEqual
(
test_id
.
uid
,
1
)
self
.
assertEqual
(
test_id
.
str_uid
,
'%0255i'
%
uid
)
self
.
assertEqual
(
test_id
.
str_filesystem
,
'%0255i'
%
uid
)
self
.
assertIs
(
test_id
.
variant
,
None
)
self
.
assertIs
(
test_id
.
str_variant
,
''
)
def
test_uid_name_uid_too_large_digitis
(
self
):
"""
Tests that when the filesystem can not cope with the size of
the Test ID, not even the test uid, an exception will be
raised.
"""
test_id
=
test
.
TestID
(
1
,
'test'
,
no_digits
=
256
)
self
.
assertRaises
(
AssertionError
,
lambda
:
test_id
.
str_filesystem
)
def
test_uid_large_name
(
self
):
"""
Tests that when the filesystem can not cope with the size of
the Test ID, the name will be shortened.
"""
uid
=
1
name
=
'test_'
*
51
# 255 characters
test_id
=
test
.
TestID
(
uid
,
name
)
self
.
assertEqual
(
test_id
.
uid
,
1
)
# only 253 can fit for the test name
self
.
assertEqual
(
test_id
.
str_filesystem
,
'%s-%s'
%
(
uid
,
name
[:
253
]))
self
.
assertIs
(
test_id
.
variant
,
None
)
self
.
assertIs
(
test_id
.
str_variant
,
""
)
def
test_uid_name_large_variant
(
self
):
"""
Tests that when the filesystem can not cope with the size of
the Test ID, and a variant name is present, the name will be
removed.
"""
uid
=
1
name
=
'test'
variant_id
=
'fast_'
*
51
# 255 characters
variant
=
{
'variant_id'
:
variant_id
}
test_id
=
test
.
TestID
(
uid
,
name
,
variant
=
variant
)
self
.
assertEqual
(
test_id
.
uid
,
1
)
self
.
assertEqual
(
test_id
.
str_filesystem
,
'%s;%s'
%
(
uid
,
variant_id
[:
253
]))
self
.
assertIs
(
test_id
.
variant
,
variant_id
)
self
.
assertEqual
(
test_id
.
str_variant
,
";%s"
%
variant_id
)
if
__name__
==
'__main__'
:
unittest
.
main
()
selftests/unit/test_utils_asset.py
浏览文件 @
bebda6eb
...
...
@@ -20,7 +20,7 @@ class TestAsset(unittest.TestCase):
self
.
url
=
'file://%s'
%
self
.
localpath
self
.
cache_dir
=
tempfile
.
mkdtemp
(
dir
=
self
.
basedir
)
def
test
F
etch_urlname
(
self
):
def
test
_f
etch_urlname
(
self
):
foo_tarball
=
asset
.
Asset
(
self
.
url
,
asset_hash
=
self
.
assethash
,
algorithm
=
'sha1'
,
...
...
@@ -30,7 +30,7 @@ class TestAsset(unittest.TestCase):
expected_tarball
=
os
.
path
.
join
(
self
.
cache_dir
,
self
.
assetname
)
self
.
assertEqual
(
foo_tarball
,
expected_tarball
)
def
test
F
etch_location
(
self
):
def
test
_f
etch_location
(
self
):
foo_tarball
=
asset
.
Asset
(
self
.
assetname
,
asset_hash
=
self
.
assethash
,
algorithm
=
'sha1'
,
...
...
@@ -40,7 +40,7 @@ class TestAsset(unittest.TestCase):
expected_tarball
=
os
.
path
.
join
(
self
.
cache_dir
,
self
.
assetname
)
self
.
assertEqual
(
foo_tarball
,
expected_tarball
)
def
test
F
ecth_expire
(
self
):
def
test
_f
ecth_expire
(
self
):
foo_tarball
=
asset
.
Asset
(
self
.
assetname
,
asset_hash
=
self
.
assethash
,
algorithm
=
'sha1'
,
...
...
@@ -81,13 +81,13 @@ class TestAsset(unittest.TestCase):
content2
=
f
.
read
()
self
.
assertNotEqual
(
content1
,
content2
)
def
test
E
xception
(
self
):
def
test
_e
xception
(
self
):
a
=
asset
.
Asset
(
name
=
'bar.tgz'
,
asset_hash
=
None
,
algorithm
=
None
,
locations
=
None
,
cache_dirs
=
[
self
.
cache_dir
],
expire
=
None
)
self
.
assertRaises
(
EnvironmentError
,
a
.
fetch
)
def
test
F
etch_lockerror
(
self
):
def
test
_f
etch_lockerror
(
self
):
with
FileLock
(
os
.
path
.
join
(
self
.
cache_dir
,
self
.
assetname
)):
a
=
asset
.
Asset
(
self
.
url
,
asset_hash
=
self
.
assethash
,
...
...
selftests/unit/test_utils_output.py
浏览文件 @
bebda6eb
...
...
@@ -5,7 +5,7 @@ from avocado.utils import output
class
UtilsOutputTest
(
unittest
.
TestCase
):
def
test
DisplayDataSizeFactor
1024
(
self
):
def
test
_display_data_size_factor_
1024
(
self
):
self
.
assertEqual
(
output
.
display_data_size
(
103
),
'103.00 B'
)
self
.
assertEqual
(
output
.
display_data_size
(
1024
**
1
),
'1.02 KB'
)
self
.
assertEqual
(
output
.
display_data_size
(
1024
**
2
),
'1.05 MB'
)
...
...
@@ -14,7 +14,7 @@ class UtilsOutputTest(unittest.TestCase):
self
.
assertEqual
(
output
.
display_data_size
(
1024
**
5
),
'1.13 PB'
)
self
.
assertEqual
(
output
.
display_data_size
(
1024
**
6
),
'1152.92 PB'
)
def
test
DisplayDataSizeFactor
1000
(
self
):
def
test
_display_data_size_factor_
1000
(
self
):
self
.
assertEqual
(
output
.
display_data_size
(
1000
**
1
),
'1.00 KB'
)
self
.
assertEqual
(
output
.
display_data_size
(
1000
**
2
),
'1.00 MB'
)
self
.
assertEqual
(
output
.
display_data_size
(
1000
**
3
),
'1.00 GB'
)
...
...
selftests/unit/test_xunit.py
浏览文件 @
bebda6eb
...
...
@@ -56,7 +56,7 @@ class xUnitSucceedTest(unittest.TestCase):
os
.
remove
(
self
.
tmpfile
[
1
])
shutil
.
rmtree
(
self
.
tmpdir
)
def
test
AddS
uccess
(
self
):
def
test
_add_s
uccess
(
self
):
self
.
test_result
.
start_test
(
self
.
test1
)
self
.
test_result
.
end_test
(
self
.
test1
.
get_state
())
self
.
test_result
.
end_tests
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录