提交 96ea1b38 编写于 作者: R Rudá Moura 提交者: Ruda Moura

avocado.plugins: Fix bug 'Namespace' object has no attribute

Fix problem when running Avocado with subcommand other than run:

$ avocado plugins
Could not activate plugin 'run_vm': 'Namespace' object has no attribute 'vm'
Could not activate plugin 'json': 'Namespace' object has no attribute 'json_output'
Could not activate plugin 'xunit': 'Namespace' object has no attribute 'xunit_output'
Could not activate plugin 'journal': 'Namespace' object has no attribute 'journal'
Plugins loaded:
    datadir      - Implements the avocado 'datadir' subcommand (Enabled)
    json         - JSON output (Enabled)
    journal      - Test journal (Enabled)
    multiplexer  - Implements the avocado 'multiplex' subcommand. (Enabled)
    plugins_list - Implements the avocado 'plugins' subcommand (Enabled)
    run_vm       - Run tests on a Virtual Machine (Enabled)
    sysinfo      - Collect system information (Enabled)
    test_lister  - Implements the avocado 'list' subcommand (Enabled)
    test_runner  - Implements the avocado 'run' subcommand (Enabled)
    xunit        - xUnit output. (Enabled)
Signed-off-by: NRuda Moura <rmoura@redhat.com>
上级 5f87c94e
......@@ -134,5 +134,8 @@ class Journal(plugin.Plugin):
self.configured = True
def activate(self, args):
if args.journal:
self.parser.application.set_defaults(journal_result=TestResultJournal)
try:
if args.journal:
self.parser.application.set_defaults(journal_result=TestResultJournal)
except AttributeError:
pass
......@@ -104,5 +104,8 @@ class JSON(plugin.Plugin):
self.configured = True
def activate(self, app_args):
if app_args.json_output:
self.parser.application.set_defaults(json_result=JSONTestResult)
try:
if app_args.json_output:
self.parser.application.set_defaults(json_result=JSONTestResult)
except AttributeError:
pass
......@@ -322,6 +322,9 @@ class RunVM(plugin.Plugin):
self.configured = True
def activate(self, app_args):
if app_args.vm:
self.parser.set_defaults(vm_result=VMTestResult,
test_runner=VMTestRunner)
try:
if app_args.vm:
self.parser.set_defaults(vm_result=VMTestResult,
test_runner=VMTestRunner)
except AttributeError:
pass
......@@ -240,5 +240,8 @@ class XUnit(plugin.Plugin):
self.configured = True
def activate(self, app_args):
if app_args.xunit_output:
self.parser.application.set_defaults(xunit_result=xUnitTestResult)
try:
if app_args.xunit_output:
self.parser.application.set_defaults(xunit_result=xUnitTestResult)
except AttributeError:
pass
......@@ -352,6 +352,17 @@ class PluginsTest(unittest.TestCase):
(expected_rc, result))
self.assertNotIn('Disabled', output)
def test_Namespace_object_has_no_attribute(self):
os.chdir(basedir)
cmd_line = './scripts/avocado plugins'
result = process.run(cmd_line, ignore_status=True)
output = result.stderr
expected_rc = 0
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
self.assertNotIn("'Namespace' object has no attribute", output)
class ParseXMLError(Exception):
pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册