Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
fcdf0c78
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,发现更多精彩内容 >>
提交
fcdf0c78
编写于
6月 18, 2015
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #695 from avocado-framework/ldoktor-runTest2
avocado.core.test: Remove the obsoleted "runTest" [v4]
上级
1ded91b9
6d0a2553
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
104 addition
and
68 deletion
+104
-68
avocado/core/test.py
avocado/core/test.py
+14
-14
docs/source/DebuggingWithGDB.rst
docs/source/DebuggingWithGDB.rst
+2
-2
examples/tests/abort.py
examples/tests/abort.py
+1
-1
examples/tests/cabort.py
examples/tests/cabort.py
+1
-1
examples/tests/datadir.py
examples/tests/datadir.py
+1
-1
examples/tests/doublefail.py
examples/tests/doublefail.py
+1
-1
examples/tests/doublefree.py
examples/tests/doublefree.py
+1
-1
examples/tests/doublefree_nasty.py
examples/tests/doublefree_nasty.py
+1
-1
examples/tests/errortest.py
examples/tests/errortest.py
+1
-1
examples/tests/failtest.py
examples/tests/failtest.py
+1
-1
examples/tests/failtest_nasty.py
examples/tests/failtest_nasty.py
+1
-1
examples/tests/failtest_nasty2.py
examples/tests/failtest_nasty2.py
+1
-1
examples/tests/fiotest.py
examples/tests/fiotest.py
+1
-1
examples/tests/gendata.py
examples/tests/gendata.py
+2
-5
examples/tests/linuxbuild.py
examples/tests/linuxbuild.py
+1
-1
examples/tests/modify_variable.py
examples/tests/modify_variable.py
+1
-1
examples/tests/multiplextest.py
examples/tests/multiplextest.py
+1
-1
examples/tests/passtest.py
examples/tests/passtest.py
+1
-1
examples/tests/raise.py
examples/tests/raise.py
+1
-1
examples/tests/skiptest.py
examples/tests/skiptest.py
+1
-1
examples/tests/sleeptenmin.py
examples/tests/sleeptenmin.py
+1
-1
examples/tests/sleeptest.py
examples/tests/sleeptest.py
+1
-1
examples/tests/synctest.py
examples/tests/synctest.py
+1
-1
examples/tests/timeouttest.py
examples/tests/timeouttest.py
+1
-1
examples/tests/trinity.py
examples/tests/trinity.py
+1
-1
examples/tests/warntest.py
examples/tests/warntest.py
+1
-1
examples/tests/whiteboard.py
examples/tests/whiteboard.py
+1
-1
requirements-travis.txt
requirements-travis.txt
+1
-0
selftests/all/functional/avocado/loader_tests.py
selftests/all/functional/avocado/loader_tests.py
+2
-2
selftests/all/functional/avocado/output_tests.py
selftests/all/functional/avocado/output_tests.py
+42
-4
selftests/all/functional/avocado/unittest_compat.py
selftests/all/functional/avocado/unittest_compat.py
+3
-3
selftests/all/unit/avocado/jsonresult_unittest.py
selftests/all/unit/avocado/jsonresult_unittest.py
+1
-1
selftests/all/unit/avocado/loader_unittest.py
selftests/all/unit/avocado/loader_unittest.py
+11
-11
selftests/all/unit/avocado/test_unittest.py
selftests/all/unit/avocado/test_unittest.py
+1
-1
selftests/all/unit/avocado/xunit_unittest.py
selftests/all/unit/avocado/xunit_unittest.py
+1
-1
未找到文件。
avocado/core/test.py
浏览文件 @
fcdf0c78
...
...
@@ -50,11 +50,11 @@ class Test(unittest.TestCase):
Base implementation for the test class.
You'll inherit from this to write your own tests. Typically you'll want
to implement setUp(),
runTest
() and tearDown() methods on your own tests.
to implement setUp(),
test*
() and tearDown() methods on your own tests.
"""
default_params
=
{}
def
__init__
(
self
,
methodName
=
'
runT
est'
,
name
=
None
,
params
=
None
,
def
__init__
(
self
,
methodName
=
'
t
est'
,
name
=
None
,
params
=
None
,
base_logdir
=
None
,
tag
=
None
,
job
=
None
,
runner_queue
=
None
):
"""
Initializes the test.
...
...
@@ -293,7 +293,7 @@ class Test(unittest.TestCase):
def
setUp
(
self
):
"""
Setup stage that the test needs before passing to the actual
runTest
.
Setup stage that the test needs before passing to the actual
test*
.
Must be implemented by tests if they want such an stage. Commonly we'll
download/compile test suites, create files needed for a test, among
...
...
@@ -303,9 +303,9 @@ class Test(unittest.TestCase):
def
tearDown
(
self
):
"""
Cleanup stage after the
runTest
is done.
Cleanup stage after the
test*
is done.
Examples of cleanup
runTests
are deleting temporary files, restoring
Examples of cleanup are deleting temporary files, restoring
firewall configurations or other system settings that were changed
in setup.
"""
...
...
@@ -342,7 +342,7 @@ class Test(unittest.TestCase):
testMethod
=
getattr
(
self
,
self
.
_testMethodName
)
self
.
_start_logging
()
self
.
sysinfo_logger
.
start_test_hook
()
runT
est_exception
=
None
t
est_exception
=
None
cleanup_exception
=
None
stdout_check_exception
=
None
stderr_check_exception
=
None
...
...
@@ -358,7 +358,7 @@ class Test(unittest.TestCase):
testMethod
()
except
Exception
,
details
:
stacktrace
.
log_exc_info
(
sys
.
exc_info
(),
logger
=
'avocado.test'
)
runT
est_exception
=
details
t
est_exception
=
details
finally
:
try
:
self
.
tearDown
()
...
...
@@ -398,8 +398,8 @@ class Test(unittest.TestCase):
self
.
record_reference_stderr
()
# pylint: disable=E0702
if
runT
est_exception
is
not
None
:
raise
runT
est_exception
if
t
est_exception
is
not
None
:
raise
t
est_exception
elif
cleanup_exception
is
not
None
:
raise
exceptions
.
TestSetupFail
(
cleanup_exception
)
elif
stdout_check_exception
is
not
None
:
...
...
@@ -556,7 +556,7 @@ class SimpleTest(Test):
self
.
log
.
info
(
"Exit status: %s"
,
result
.
exit_status
)
self
.
log
.
info
(
"Duration: %s"
,
result
.
duration
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Run the executable, and log its detailed execution.
"""
...
...
@@ -586,7 +586,7 @@ class MissingTest(Test):
Handle when there is no such test module in the test directory.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
e_msg
=
(
'Test %s could not be found in the test dir %s '
'(or test path does not exist)'
%
(
self
.
name
,
data_dir
.
get_test_dir
()))
...
...
@@ -602,7 +602,7 @@ class BuggyTest(Test):
buggy python module.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
# pylint: disable=E0702
raise
self
.
params
.
get
(
'exception'
)
...
...
@@ -616,7 +616,7 @@ class NotATest(Test):
or a regular, non executable file.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
e_msg
=
(
'File %s is not executable and does not contain an avocado '
'test class in it '
%
self
.
name
)
raise
exceptions
.
NotATestError
(
e_msg
)
...
...
@@ -631,6 +631,6 @@ class TimeOutSkipTest(Test):
It will never have a chance to execute.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
e_msg
=
'Test skipped due a job timeout!'
raise
exceptions
.
TestNAError
(
e_msg
)
docs/source/DebuggingWithGDB.rst
浏览文件 @
fcdf0c78
...
...
@@ -92,7 +92,7 @@ test::
class HelloOutputTest(Test):
def
runT
est(self):
def
t
est(self):
result = process.run("/path/to/hello", ignore_status=True)
self.assertIn("hello\n", result.stdout)
...
...
@@ -154,7 +154,7 @@ Example
Take a look at ``examples/tests/modify_variable.py`` test::
def
runT
est(self):
def
t
est(self):
"""
Execute 'print_variable'.
"""
...
...
examples/tests/abort.py
浏览文件 @
fcdf0c78
...
...
@@ -14,7 +14,7 @@ class AbortTest(Test):
default_params
=
{
'timeout'
:
2.0
}
def
runT
est
(
self
):
def
t
est
(
self
):
os
.
abort
()
...
...
examples/tests/cabort.py
浏览文件 @
fcdf0c78
...
...
@@ -27,7 +27,7 @@ class CAbort(Test):
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
'abort'
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'abort'.
"""
...
...
examples/tests/datadir.py
浏览文件 @
fcdf0c78
...
...
@@ -28,7 +28,7 @@ class DataDirTest(Test):
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
'datadir'
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'datadir'.
"""
...
...
examples/tests/doublefail.py
浏览文件 @
fcdf0c78
...
...
@@ -10,7 +10,7 @@ class DoubleFail(Test):
Functional test for avocado. Straight up fail the test.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Should fail.
"""
...
...
examples/tests/doublefree.py
浏览文件 @
fcdf0c78
...
...
@@ -29,7 +29,7 @@ class DoubleFreeTest(Test):
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
'doublefree'
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'doublefree'.
"""
...
...
examples/tests/doublefree_nasty.py
浏览文件 @
fcdf0c78
...
...
@@ -29,7 +29,7 @@ class DoubleFreeTest(Test):
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
self
.
__binary
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'doublefree'.
"""
...
...
examples/tests/errortest.py
浏览文件 @
fcdf0c78
...
...
@@ -10,7 +10,7 @@ class ErrorTest(Test):
Example test that ends with ERROR.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
This should end with ERROR.
"""
...
...
examples/tests/failtest.py
浏览文件 @
fcdf0c78
...
...
@@ -10,7 +10,7 @@ class FailTest(Test):
Example test for avocado. Straight up fail the test.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Should fail.
"""
...
...
examples/tests/failtest_nasty.py
浏览文件 @
fcdf0c78
...
...
@@ -21,7 +21,7 @@ class FailTest(Test):
Very nasty exception test
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Should fail not-that-badly
"""
...
...
examples/tests/failtest_nasty2.py
浏览文件 @
fcdf0c78
...
...
@@ -21,7 +21,7 @@ class FailTest(Test):
Very nasty exception test
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Should fail.
"""
...
...
examples/tests/fiotest.py
浏览文件 @
fcdf0c78
...
...
@@ -30,7 +30,7 @@ class FioTest(Test):
self
.
srcdir
=
os
.
path
.
join
(
self
.
srcdir
,
fio_version
)
build
.
make
(
self
.
srcdir
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'fio' with appropriate parameters.
"""
...
...
examples/tests/gendata.py
浏览文件 @
fcdf0c78
...
...
@@ -12,7 +12,7 @@ class GenDataTest(Test):
Simple test that generates data to be persisted after the test is run
"""
def
generate
_bsod
(
self
):
def
test
_bsod
(
self
):
try
:
from
PIL
import
Image
from
PIL
import
ImageDraw
...
...
@@ -34,16 +34,13 @@ class GenDataTest(Test):
y
+=
12
bsod
.
save
(
os
.
path
.
join
(
self
.
outputdir
,
"bsod.png"
))
def
generate
_json
(
self
):
def
test
_json
(
self
):
import
json
output_path
=
os
.
path
.
join
(
self
.
outputdir
,
"test.json"
)
output
=
{
"basedir"
:
self
.
basedir
,
"outputdir"
:
self
.
outputdir
}
json
.
dump
(
output
,
open
(
output_path
,
"w"
))
def
runTest
(
self
):
self
.
generate_bsod
()
self
.
generate_json
()
if
__name__
==
"__main__"
:
main
()
examples/tests/linuxbuild.py
浏览文件 @
fcdf0c78
...
...
@@ -22,7 +22,7 @@ class LinuxBuildTest(Test):
self
.
linux_build
.
uncompress
()
self
.
linux_build
.
configure
()
def
runT
est
(
self
):
def
t
est
(
self
):
self
.
linux_build
.
build
()
...
...
examples/tests/modify_variable.py
浏览文件 @
fcdf0c78
...
...
@@ -32,7 +32,7 @@ class PrintVariableTest(Test):
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
self
.
__binary
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'print_variable'.
"""
...
...
examples/tests/multiplextest.py
浏览文件 @
fcdf0c78
...
...
@@ -55,7 +55,7 @@ class MultiplexTest(Test):
if
enable_msx_vectors
==
'yes'
:
self
.
log
.
info
(
'Enabling msx vectors'
)
def
runT
est
(
self
):
def
t
est
(
self
):
self
.
log
.
info
(
'Executing synctest...'
)
self
.
log
.
info
(
'synctest --timeout %s --tries %s'
,
self
.
params
.
get
(
'sync_timeout'
,
default
=
12
),
...
...
examples/tests/passtest.py
浏览文件 @
fcdf0c78
...
...
@@ -10,7 +10,7 @@ class PassTest(Test):
Example test that passes.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
A test simply doesn't have to fail in order to pass
"""
...
...
examples/tests/raise.py
浏览文件 @
fcdf0c78
...
...
@@ -28,7 +28,7 @@ class Raise(Test):
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
'raise'
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute 'raise'.
"""
...
...
examples/tests/skiptest.py
浏览文件 @
fcdf0c78
...
...
@@ -10,7 +10,7 @@ class SkipTest(Test):
Example test that skips the current test, that is it, ends with SKIP.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
This should end with SKIP.
"""
...
...
examples/tests/sleeptenmin.py
浏览文件 @
fcdf0c78
...
...
@@ -13,7 +13,7 @@ class SleepTenMin(Test):
Sleeps for 10 minutes
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Sleep for length seconds.
"""
...
...
examples/tests/sleeptest.py
浏览文件 @
fcdf0c78
...
...
@@ -12,7 +12,7 @@ class SleepTest(Test):
Example test for avocado.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Sleep for length seconds.
"""
...
...
examples/tests/synctest.py
浏览文件 @
fcdf0c78
...
...
@@ -31,7 +31,7 @@ class SyncTest(Test):
else
:
build
.
make
(
self
.
srcdir
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute synctest with the appropriate params.
"""
...
...
examples/tests/timeouttest.py
浏览文件 @
fcdf0c78
...
...
@@ -14,7 +14,7 @@ class TimeoutTest(Test):
default_params
=
{
'timeout'
:
3
}
def
runT
est
(
self
):
def
t
est
(
self
):
"""
This should throw a TestTimeoutError.
"""
...
...
examples/tests/trinity.py
浏览文件 @
fcdf0c78
...
...
@@ -37,7 +37,7 @@ class TrinityTest(Test):
build
.
make
(
self
.
srcdir
)
self
.
victims_path
=
data_factory
.
make_dir_and_populate
(
self
.
workdir
)
def
runT
est
(
self
):
def
t
est
(
self
):
"""
Execute the trinity syscall fuzzer with the appropriate params.
"""
...
...
examples/tests/warntest.py
浏览文件 @
fcdf0c78
...
...
@@ -10,7 +10,7 @@ class WarnTest(Test):
Functional test for avocado. Throw a TestWarn.
"""
def
runT
est
(
self
):
def
t
est
(
self
):
"""
This should throw a TestWarn.
"""
...
...
examples/tests/whiteboard.py
浏览文件 @
fcdf0c78
...
...
@@ -12,7 +12,7 @@ class WhiteBoard(Test):
Simple test that saves test custom data to the test whiteboard
"""
def
runT
est
(
self
):
def
t
est
(
self
):
data_file
=
self
.
params
.
get
(
'whiteboard_data_file'
,
default
=
''
)
data_size
=
self
.
params
.
get
(
'whiteboard_data_size'
,
default
=
'10'
)
if
data_file
:
...
...
requirements-travis.txt
浏览文件 @
fcdf0c78
...
...
@@ -8,3 +8,4 @@ inspektor==0.1.15
pep8==1.6.2
requests==1.2.3
PyYAML==3.11
Pillow==2.2.1
selftests/all/functional/avocado/loader_tests.py
浏览文件 @
fcdf0c78
...
...
@@ -22,7 +22,7 @@ from avocado import Test
from avocado import main
class PassTest(Test):
def
runT
est(self):
def
t
est(self):
pass
if __name__ == "__main__":
...
...
@@ -35,7 +35,7 @@ from avocado import main
import adsh
class PassTest(Test):
def
runT
est(self):
def
t
est(self):
pass
if __name__ == "__main__":
...
...
selftests/all/functional/avocado/output_tests.py
浏览文件 @
fcdf0c78
...
...
@@ -244,10 +244,9 @@ class OutputPluginTest(unittest.TestCase):
(
expected_rc
,
result
))
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
debug_dir
=
os
.
path
.
dirname
(
debug_log
)
test_result_dir
=
os
.
path
.
join
(
debug_dir
,
'test-results'
,
'whiteboard.py'
)
whiteboard_path
=
os
.
path
.
join
(
test_result_dir
,
'whiteboard'
)
logfile
=
json_results
[
'tests'
][
0
][
'logfile'
]
debug_dir
=
os
.
path
.
dirname
(
logfile
)
whiteboard_path
=
os
.
path
.
join
(
debug_dir
,
'whiteboard'
)
self
.
assertTrue
(
os
.
path
.
exists
(
whiteboard_path
),
'Missing whiteboard file %s'
%
whiteboard_path
)
finally
:
...
...
@@ -256,6 +255,45 @@ class OutputPluginTest(unittest.TestCase):
except
OSError
:
pass
def
test_gendata
(
self
):
tmpfile
=
tempfile
.
mktemp
()
try
:
os
.
chdir
(
basedir
)
cmd_line
=
(
"./scripts/avocado run --job-results-dir %s "
"--sysinfo=off gendata --json %s"
%
(
self
.
tmpdir
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
0
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
bsod_dir
=
None
json_dir
=
None
for
test
in
json_results
[
'tests'
]:
if
"test_bsod"
in
test
[
'url'
]:
bsod_dir
=
test
[
'logfile'
]
elif
"test_json"
in
test
[
'url'
]:
json_dir
=
test
[
'logfile'
]
self
.
assertTrue
(
bsod_dir
,
"Failed to get test_bsod output "
"directory"
)
self
.
assertTrue
(
json_dir
,
"Failed to get test_json output "
"directory"
)
bsod_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
bsod_dir
),
"data"
,
"bsod.png"
)
json_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
json_dir
),
"data"
,
"test.json"
)
self
.
assertTrue
(
os
.
path
.
exists
(
bsod_dir
),
"File %s produced by"
"test does not exist"
%
bsod_dir
)
self
.
assertTrue
(
os
.
path
.
exists
(
json_dir
),
"File %s produced by"
"test does not exist"
%
json_dir
)
finally
:
try
:
os
.
remove
(
tmpfile
)
except
OSError
:
pass
def
test_redirect_output
(
self
):
redirected_output_path
=
tempfile
.
mktemp
()
try
:
...
...
selftests/all/functional/avocado/unittest_compat.py
浏览文件 @
fcdf0c78
...
...
@@ -19,7 +19,7 @@ from avocado.utils import process
UNITTEST_GOOD
=
"""from avocado import Test
from unittest import main
class AvocadoPassTest(Test):
def
runT
est(self):
def
t
est(self):
self.assertTrue(True)
if __name__ == '__main__':
main()
...
...
@@ -28,7 +28,7 @@ if __name__ == '__main__':
UNITTEST_FAIL
=
"""from avocado import Test
from unittest import main
class AvocadoFailTest(Test):
def
runT
est(self):
def
t
est(self):
self.fail('This test is supposed to fail')
if __name__ == '__main__':
main()
...
...
@@ -37,7 +37,7 @@ if __name__ == '__main__':
UNITTEST_ERROR
=
"""from avocado import Test
from unittest import main
class AvocadoErrorTest(Test):
def
runT
est(self):
def
t
est(self):
self.error('This test is supposed to error')
if __name__ == '__main__':
main()
...
...
selftests/all/unit/avocado/jsonresult_unittest.py
浏览文件 @
fcdf0c78
...
...
@@ -44,7 +44,7 @@ class JSONResultTest(unittest.TestCase):
class
SimpleTest
(
Test
):
def
runT
est
(
self
):
def
t
est
(
self
):
pass
self
.
tmpfile
=
tempfile
.
mkstemp
()
...
...
selftests/all/unit/avocado/loader_unittest.py
浏览文件 @
fcdf0c78
...
...
@@ -23,7 +23,7 @@ from avocado import Test
from avocado import main
class PassTest(Test):
def
runT
est(self):
def
t
est(self):
pass
if __name__ == "__main__":
...
...
@@ -36,7 +36,7 @@ from avocado import main
import adsh
class PassTest(Test):
def
runT
est(self):
def
t
est(self):
pass
if __name__ == "__main__":
...
...
@@ -103,7 +103,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
simple_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
SimpleTest
,
test_class
)
tc
=
test_class
(
**
test_parameters
)
tc
.
runT
est
()
tc
.
t
est
()
simple_test
.
remove
()
def
test_load_simple_not_exec
(
self
):
...
...
@@ -115,7 +115,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
simple_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
NotATest
,
test_class
)
tc
=
test_class
(
**
test_parameters
)
self
.
assertRaises
(
exceptions
.
NotATestError
,
tc
.
runT
est
)
self
.
assertRaises
(
exceptions
.
NotATestError
,
tc
.
t
est
)
simple_test
.
remove
()
def
test_load_pass
(
self
):
...
...
@@ -129,7 +129,7 @@ class LoaderTest(unittest.TestCase):
str
(
test_class
))
self
.
assertTrue
(
issubclass
(
test_class
,
test
.
Test
))
tc
=
test_class
(
**
test_parameters
)
tc
.
runT
est
()
tc
.
t
est
()
avocado_pass_test
.
remove
()
def
test_load_inherited
(
self
):
...
...
@@ -162,7 +162,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
avocado_buggy_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
SimpleTest
,
test_class
)
tc
=
test_class
(
**
test_parameters
)
self
.
assertRaises
(
exceptions
.
TestFail
,
tc
.
runT
est
)
self
.
assertRaises
(
exceptions
.
TestFail
,
tc
.
t
est
)
avocado_buggy_test
.
remove
()
def
test_load_buggy_not_exec
(
self
):
...
...
@@ -175,7 +175,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
avocado_buggy_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
BuggyTest
,
test_class
)
tc
=
test_class
(
**
test_parameters
)
self
.
assertRaises
(
ImportError
,
tc
.
runT
est
)
self
.
assertRaises
(
ImportError
,
tc
.
t
est
)
avocado_buggy_test
.
remove
()
def
test_load_not_a_test
(
self
):
...
...
@@ -188,7 +188,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
avocado_not_a_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
NotATest
,
test_class
)
tc
=
test_class
(
**
test_parameters
)
self
.
assertRaises
(
exceptions
.
NotATestError
,
tc
.
runT
est
)
self
.
assertRaises
(
exceptions
.
NotATestError
,
tc
.
t
est
)
avocado_not_a_test
.
remove
()
def
test_load_not_a_test_exec
(
self
):
...
...
@@ -201,7 +201,7 @@ class LoaderTest(unittest.TestCase):
tc
=
test_class
(
**
test_parameters
)
# The test can't be executed (no shebang), raising an OSError
# (OSError: [Errno 8] Exec format error)
self
.
assertRaises
(
OSError
,
tc
.
runT
est
)
self
.
assertRaises
(
OSError
,
tc
.
t
est
)
avocado_not_a_test
.
remove
()
def
test_py_simple_test
(
self
):
...
...
@@ -213,7 +213,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
avocado_simple_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
SimpleTest
)
tc
=
test_class
(
**
test_parameters
)
tc
.
runT
est
()
tc
.
t
est
()
avocado_simple_test
.
remove
()
def
test_py_simple_test_notexec
(
self
):
...
...
@@ -226,7 +226,7 @@ class LoaderTest(unittest.TestCase):
self
.
loader
.
discover_tests
(
params
=
{
'id'
:
avocado_simple_test
.
path
})[
0
])
self
.
assertTrue
(
test_class
==
test
.
NotATest
)
tc
=
test_class
(
**
test_parameters
)
self
.
assertRaises
(
exceptions
.
NotATestError
,
tc
.
runT
est
)
self
.
assertRaises
(
exceptions
.
NotATestError
,
tc
.
t
est
)
avocado_simple_test
.
remove
()
def
test_multiple_methods
(
self
):
...
...
selftests/all/unit/avocado/test_unittest.py
浏览文件 @
fcdf0c78
...
...
@@ -31,7 +31,7 @@ class TestClassTest(unittest.TestCase):
def
setUp
(
self
):
class
AvocadoPass
(
test
.
Test
):
def
runT
est
(
self
):
def
t
est
(
self
):
variable
=
True
self
.
assertTrue
(
variable
)
self
.
whiteboard
=
'foo'
...
...
selftests/all/unit/avocado/xunit_unittest.py
浏览文件 @
fcdf0c78
...
...
@@ -48,7 +48,7 @@ class xUnitSucceedTest(unittest.TestCase):
class
SimpleTest
(
Test
):
def
runT
est
(
self
):
def
t
est
(
self
):
pass
self
.
tmpfile
=
tempfile
.
mkstemp
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录