Skip to content

Commit

Permalink
Merge pull request #643 from clebergnu/api_review_2nd_round_reviewed_…
Browse files Browse the repository at this point in the history
…bits_v3

API Review (2nd round) - Reviewed Bits - v3
  • Loading branch information
ruda committed Jun 8, 2015
2 parents 3f661b6 + b08ad8c commit b18a056
Show file tree
Hide file tree
Showing 56 changed files with 197 additions and 206 deletions.
5 changes: 5 additions & 0 deletions avocado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>


__all__ = ['main', 'Test']


import logging

from avocado.core.job import main
from avocado.core.test import Test


if hasattr(logging, 'NullHandler'):
Expand Down
21 changes: 0 additions & 21 deletions avocado/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,3 @@ class TestWarn(TestBaseException):
failure.
"""
status = "WARN"


class CmdError(Exception):

def __init__(self, command=None, result=None):
self.command = command
self.result = result

def __str__(self):
if self.result is not None:
if self.result.interrupted:
return "Command %s interrupted by user (Ctrl+C)" % self.command
if self.result.exit_status is None:
msg = "Command '%s' failed and is not responding to signals"
msg %= self.command
else:
msg = "Command '%s' failed (rc=%d)"
msg %= (self.command, self.result.exit_status)
return msg
else:
return "CmdError"
6 changes: 3 additions & 3 deletions avocado/core/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import re
import sys

from avocado import test
from avocado import data_dir
from avocado.core import test
from avocado.utils import path
from avocado.core import output

Expand Down Expand Up @@ -144,7 +144,7 @@ def load_test(self, test_factory):
:param test_factory: a pair of test class and parameters.
:type params: tuple
:return: an instance of :class:`avocado.test.Testself`.
:return: an instance of :class:`avocado.core.test.Test`.
"""
test_class, test_parameters = test_factory
test_instance = test_class(**test_parameters)
Expand Down Expand Up @@ -539,7 +539,7 @@ def load_test(self, test_factory):
:param test_factory: a pair of test class and parameters.
:type params: tuple
:return: an instance of :class:`avocado.test.Testself`.
:return: an instance of :class:`avocado.core.test.Test`.
"""
test_class, test_parameters = test_factory
test_instance = test_class(**test_parameters)
Expand Down
6 changes: 3 additions & 3 deletions avocado/core/plugins/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from avocado.core.plugins import plugin
from avocado.utils import process
from avocado.utils import path as utils_path
from avocado.linux import distro as distro_utils
from avocado.utils import distro as utils_distro


class SoftwarePackage(object):
Expand Down Expand Up @@ -55,7 +55,7 @@ def to_json(self):
return json.dumps(self.to_dict())


class DistroDef(distro_utils.LinuxDistro):
class DistroDef(utils_distro.LinuxDistro):

"""
More complete information on a given Linux Distribution
Expand Down Expand Up @@ -373,7 +373,7 @@ def run(self, args):
msg=('Distro information saved '
'to "%s"' % output_file_name))
else:
detected = distro_utils.detect()
detected = utils_distro.detect()
msg = 'Detected distribution: %s (%s) version %s release %s' % (
detected.name,
detected.arch,
Expand Down
2 changes: 1 addition & 1 deletion avocado/core/plugins/htmlresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def end_test(self, state):
"""
Called when the given test has been run.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.end_test(self, state)
Expand Down
2 changes: 1 addition & 1 deletion avocado/core/plugins/jsonresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def end_test(self, state):
"""
Called when the given test has been run.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.end_test(self, state)
Expand Down
2 changes: 1 addition & 1 deletion avocado/core/plugins/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import sys

from avocado import test
from avocado.core import test
from avocado.core import loader
from avocado.core import output
from avocado.core import exit_codes
Expand Down
10 changes: 5 additions & 5 deletions avocado/core/plugins/xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def add_success(self, state):
"""
Add a testcase node of kind succeed.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
tc = '\t<testcase classname={class} name={name} time="{time}"/>'
Expand All @@ -95,7 +95,7 @@ def add_skip(self, state):
"""
Add a testcase node of kind skipped.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
tc = '''\t<testcase classname={class} name={name} time="{time}">
Expand All @@ -110,7 +110,7 @@ def add_failure(self, state):
"""
Add a testcase node of kind failed.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
tc = '''\t<testcase classname={class} name={name} time="{time}">
Expand All @@ -130,7 +130,7 @@ def add_error(self, state):
"""
Add a testcase node of kind error.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
tc = '''\t<testcase classname={class} name={name} time="{time}">
Expand Down Expand Up @@ -184,7 +184,7 @@ def end_test(self, state):
"""
Record an end test event, accord to the given test status.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.end_test(self, state)
Expand Down
2 changes: 1 addition & 1 deletion avocado/core/remote/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class RemoteTest(object):

"""
Mimics :class:`avocado.test.Test` for remote tests.
Mimics :class:`avocado.core.test.Test` for remote tests.
"""

def __init__(self, name, status, time, start, end, fail_reason, logdir,
Expand Down
30 changes: 15 additions & 15 deletions avocado/core/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def start_test(self, state):
"""
Called when the given test is about to run.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
pass
Expand All @@ -174,7 +174,7 @@ def end_test(self, state):
"""
Called when the given test has been run.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.tests_run += 1
Expand All @@ -185,7 +185,7 @@ def add_pass(self, state):
"""
Called when a test succeeded.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.passed.append(state)
Expand All @@ -194,7 +194,7 @@ def add_error(self, state):
"""
Called when a test had a setup error.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.errors.append(state)
Expand All @@ -203,7 +203,7 @@ def add_fail(self, state):
"""
Called when a test fails.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.failed.append(state)
Expand All @@ -212,15 +212,15 @@ def add_skip(self, state):
"""
Called when a test is skipped.
:param test: an instance of :class:`avocado.test.Test`.
:param test: an instance of :class:`avocado.core.test.Test`.
"""
self.skipped.append(state)

def add_warn(self, state):
"""
Called when a test had a warning.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.warned.append(state)
Expand All @@ -229,7 +229,7 @@ def add_interrupt(self, state):
"""
Called when a test is interrupted by the user.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.interrupted.append(state)
Expand Down Expand Up @@ -289,7 +289,7 @@ def start_test(self, state):
"""
Called when the given test is about to run.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
self.stream.add_test(state)
Expand All @@ -298,7 +298,7 @@ def end_test(self, state):
"""
Called when the given test has been run.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.end_test(self, state)
Expand All @@ -307,7 +307,7 @@ def add_pass(self, state):
"""
Called when a test succeeded.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.add_pass(self, state)
Expand All @@ -317,7 +317,7 @@ def add_error(self, state):
"""
Called when a test had a setup error.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.add_error(self, state)
Expand All @@ -327,7 +327,7 @@ def add_fail(self, state):
"""
Called when a test fails.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.add_fail(self, state)
Expand All @@ -337,7 +337,7 @@ def add_skip(self, state):
"""
Called when a test is skipped.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.add_skip(self, state)
Expand All @@ -347,7 +347,7 @@ def add_warn(self, state):
"""
Called when a test had a warning.
:param state: result of :class:`avocado.test.Test.get_state`.
:param state: result of :class:`avocado.core.test.Test.get_state`.
:type state: dict
"""
TestResult.add_warn(self, state)
Expand Down
6 changes: 3 additions & 3 deletions avocado/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import sys
import time

from avocado import test
from avocado import runtime
from avocado.core import test
from avocado.core import exceptions
from avocado.core import output
from avocado.core import status
Expand Down Expand Up @@ -57,7 +57,7 @@ def _run_test(self, test_factory, queue):
Run a test instance.
:param test_factory: Test factory (test class and parameters).
:type test_factory: tuple of :class:`avocado.test.Test` and dict.
:type test_factory: tuple of :class:`avocado.core.test.Test` and dict.
:param queue: Multiprocess queue.
:type queue: :class`multiprocessing.Queue` instance.
"""
Expand Down Expand Up @@ -117,7 +117,7 @@ def run_test(self, test_factory, queue, failures, job_deadline=0):
Run a test instance inside a subprocess.
:param test_factory: Test factory (test class and parameters).
:type test_factory: tuple of :class:`avocado.test.Test` and dict.
:type test_factory: tuple of :class:`avocado.core.test.Test` and dict.
:param queue: Multiprocess queue.
:type queue: :class`multiprocessing.Queue` instance.
:param failures: Store tests failed.
Expand Down

0 comments on commit b18a056

Please sign in to comment.