提交 813f3b24 编写于 作者: L Lucas Meneghel Rodrigues

Merge pull request #652 from clebergnu/api_review_2nd_round_2nd_batch_all_but_tests

API Review (2nd round, 2nd batch) - All commits but Exceptions
Summary: Avocado Test Framework
Name: avocado
Version: 0.24.0
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2
Group: Development/Tools
URL: http://avocado-framework.github.io/
......@@ -101,9 +101,11 @@ examples of how to write tests on your own.
%files examples
%{_datadir}/avocado/tests
%{_datadir}/avocado/wrappers
%{_datadir}/avocado/api
%changelog
* Fri Jun 5 2015 Cleber Rosa <cleber@redhat.com> - 0.24.0-3
- Removed rest client API examples
* Mon May 25 2015 Cleber Rosa <cleber@redhat.com> - 0.24.0-2
- Added previously missing gdb.conf
......
......@@ -16,111 +16,5 @@
__all__ = ['main', 'Test']
import logging
from avocado.core.job import main
from avocado.core.test import Test
if hasattr(logging, 'NullHandler'):
NULL_HANDLER = 'logging.NullHandler'
else:
NULL_HANDLER = 'logutils.NullHandler'
DEFAULT_LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'brief': {
'format': '%(message)s',
},
},
'filters': {
'error': {
'()': 'avocado.core.output.FilterError',
},
'info': {
'()': 'avocado.core.output.FilterInfo',
},
},
'handlers': {
'null': {
'level': 'INFO',
'class': NULL_HANDLER,
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'brief',
},
'app': {
'level': 'INFO',
'class': 'avocado.core.output.ProgressStreamHandler',
'formatter': 'brief',
'filters': ['info'],
'stream': 'ext://sys.stdout',
},
'error': {
'level': 'ERROR',
'class': 'logging.StreamHandler',
'formatter': 'brief',
'filters': ['error'],
},
'debug': {
'level': 'DEBUG',
'class': 'avocado.core.output.ProgressStreamHandler',
'formatter': 'brief',
'stream': 'ext://sys.stdout',
},
},
'loggers': {
'avocado': {
'handlers': ['console'],
},
'avocado.app': {
'handlers': ['app', 'error'],
'level': 'INFO',
'propagate': False,
},
'avocado.test': {
'handlers': ['null'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.test.stdout': {
'handlers': ['null'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.test.stderr': {
'handlers': ['null'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.sysinfo': {
'handlers': ['error'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.debug': {
'handlers': ['debug'],
'level': 'DEBUG',
'propagate': False,
},
}
}
from logging import config
if not hasattr(config, 'dictConfig'):
from logutils import dictconfig
cfg_func = dictconfig.dictConfig
else:
cfg_func = config.dictConfig
cfg_func(DEFAULT_LOGGING)
# Don't export these names outside avocado namespace
del logging
del config
del cfg_func
......@@ -18,6 +18,7 @@ The core Avocado application.
import os
from avocado.core.log import configure
from avocado.core.parser import Parser
from avocado.core.plugins.manager import get_plugin_manager
......@@ -33,6 +34,7 @@ class AvocadoApp(object):
# Catch all libc runtime errors to STDERR
os.environ['LIBC_FATAL_STDERR_'] = '1'
configure()
self.external_plugins = external_plugins
self.plugin_manager = None
self.parser = Parser()
......
......@@ -34,12 +34,12 @@ import time
import tempfile
from avocado.core import job_id
from avocado.core.settings import settings
from avocado.utils import path as utils_path
from avocado.utils.data_structures import Borg
from avocado.settings import settings
_BASE_DIR = os.path.join(sys.modules[__name__].__file__, "..", "..")
_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')
......
......@@ -26,9 +26,8 @@ import tempfile
import shutil
import fnmatch
from avocado import multiplexer
from avocado import runtime
from avocado import data_dir
from avocado.core import data_dir
from avocado.core import runner
from avocado.core import loader
from avocado.core import sysinfo
......@@ -37,13 +36,13 @@ from avocado.core import exit_codes
from avocado.core import exceptions
from avocado.core import job_id
from avocado.core import output
from avocado.core import multiplexer
from avocado.core.settings import settings
from avocado.core.plugins import jsonresult
from avocado.core.plugins import xunit
from avocado.core.plugins.builtin import ErrorsLoading
from avocado.utils import archive
from avocado.utils import path
from avocado.settings import settings
from avocado.core.plugins.builtin import ErrorsLoading
try:
......
......@@ -23,7 +23,7 @@ import os
import re
import sys
from avocado import data_dir
from avocado.core import data_dir
from avocado.core import test
from avocado.utils import path
from avocado.core import output
......
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
__all__ = ['configure', 'DEFAULT_LOGGING']
import logging
if hasattr(logging, 'NullHandler'):
NULL_HANDLER = 'logging.NullHandler'
else:
NULL_HANDLER = 'logutils.NullHandler'
DEFAULT_LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'brief': {
'format': '%(message)s',
},
},
'filters': {
'error': {
'()': 'avocado.core.output.FilterError',
},
'info': {
'()': 'avocado.core.output.FilterInfo',
},
},
'handlers': {
'null': {
'level': 'INFO',
'class': NULL_HANDLER,
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'brief',
},
'app': {
'level': 'INFO',
'class': 'avocado.core.output.ProgressStreamHandler',
'formatter': 'brief',
'filters': ['info'],
'stream': 'ext://sys.stdout',
},
'error': {
'level': 'ERROR',
'class': 'logging.StreamHandler',
'formatter': 'brief',
'filters': ['error'],
},
'debug': {
'level': 'DEBUG',
'class': 'avocado.core.output.ProgressStreamHandler',
'formatter': 'brief',
'stream': 'ext://sys.stdout',
},
},
'loggers': {
'avocado': {
'handlers': ['console'],
},
'avocado.app': {
'handlers': ['app', 'error'],
'level': 'INFO',
'propagate': False,
},
'avocado.test': {
'handlers': ['null'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.test.stdout': {
'handlers': ['null'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.test.stderr': {
'handlers': ['null'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.sysinfo': {
'handlers': ['error'],
'level': 'DEBUG',
'propagate': False,
},
'avocado.debug': {
'handlers': ['debug'],
'level': 'DEBUG',
'propagate': False,
},
}
}
def configure(logging_config=DEFAULT_LOGGING):
from logging import config
if not hasattr(config, 'dictConfig'):
from logutils import dictconfig
cfg_func = dictconfig.dictConfig
else:
cfg_func = config.dictConfig
cfg_func(logging_config)
......@@ -20,7 +20,7 @@ import os
import sys
from avocado.utils import path as utils_path
from avocado.settings import settings
from avocado.core.settings import settings
class FilterError(logging.Filter):
......
......@@ -13,8 +13,8 @@
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
from avocado.core import output
from avocado import data_dir
from avocado.settings import settings
from avocado.core import data_dir
from avocado.core.settings import settings
from avocado.core.plugins import plugin
......
......@@ -17,7 +17,7 @@
from avocado import runtime
from avocado.utils import path as utils_path
from avocado.core.plugins import plugin
from avocado.settings import settings
from avocado.core.settings import settings
class GDB(plugin.Plugin):
......
......@@ -18,7 +18,7 @@ from avocado.core.plugins import plugin
from avocado.core import output
from avocado.core import exit_codes
from avocado.core import tree
from avocado import multiplexer
from avocado.core import multiplexer
class Multiplexer(plugin.Plugin):
......
......@@ -18,12 +18,12 @@ Base Test Runner Plugins.
import sys
from avocado.settings import settings
from avocado.core.settings import settings
from avocado.core import exit_codes
from avocado.core.plugins import plugin
from avocado.core import output
from avocado.core import job
from avocado import multiplexer
from avocado.core import multiplexer
class TestRunner(plugin.Plugin):
......
......@@ -16,7 +16,7 @@
import os
from avocado import data_dir
from avocado.core import data_dir
from avocado.core import exceptions
from avocado.core.result import HumanTestResult
from avocado.utils import remote
......
......@@ -6,7 +6,7 @@ Module that implements the actions for the CLI App when the job toplevel
command is used
"""
from avocado.restclient import connection
from avocado.core.restclient import connection
from avocado.core.restclient.cli.actions import base
......
......@@ -22,10 +22,10 @@ import types
import importlib
import functools
from avocado import settings
from avocado.restclient import connection
from avocado.core import settings
from avocado.core import output
from avocado.core import exit_codes
from avocado.core.restclient import connection
from avocado.core.restclient.cli import parser
__all__ = ['App']
......
......@@ -21,7 +21,7 @@ basic object that allows methods to be called on the remote server.
import requests
from avocado.settings import settings
from avocado.core.settings import settings
__all__ = ['get_default', 'Connection']
......
......@@ -31,7 +31,7 @@ else:
_config_dir_system = os.path.join(CFG_DIR, 'avocado')
_config_dir_system_extra = os.path.join(CFG_DIR, 'avocado', 'conf.d')
_config_dir_local = os.path.join(os.path.expanduser("~"), '.config', 'avocado')
_source_tree_root = os.path.join(sys.modules[__name__].__file__, "..", "..")
_source_tree_root = os.path.join(sys.modules[__name__].__file__, "..", "..", "..")
_config_path_intree = os.path.join(os.path.abspath(_source_tree_root), 'etc', 'avocado')
_config_path_intree_extra = os.path.join(os.path.abspath(_source_tree_root), 'etc', 'avocado', 'conf.d')
......
......@@ -28,7 +28,7 @@ from avocado.utils import process
from avocado.utils import software_manager
from avocado.utils import path as utils_path
from avocado.core import output
from avocado.settings import settings
from avocado.core.settings import settings
log = logging.getLogger("avocado.sysinfo")
......
......@@ -31,10 +31,10 @@ if sys.version_info[:2] == (2, 6):
else:
import unittest
from avocado import data_dir
from avocado import multiplexer
from avocado.core import data_dir
from avocado.core import sysinfo
from avocado.core import exceptions
from avocado.core import multiplexer
from avocado.utils import genio
from avocado.utils import path as utils_path
from avocado.utils import process
......
......@@ -14,7 +14,7 @@
import os
import process
from . import process
def make(path, make='make', env=None, extra_args='', ignore_status=False, allow_output_check='none'):
......
......@@ -23,7 +23,7 @@ import socket
import shutil
import urllib2
from avocado.utils import aurl
from . import aurl
log = logging.getLogger('avocado.test')
......
......@@ -30,8 +30,8 @@ try:
except ImportError:
import subprocess
from avocado.utils import network
from avocado.core import gdbmi_parser
from . import network
from .external import gdbmi_parser
GDB_PROMPT = '(gdb)'
GDB_EXIT = '^exit'
......
......@@ -20,7 +20,7 @@ import logging
import os
import time
from avocado.utils import path as utils_path
from . import path as utils_path
log = logging.getLogger('avocado.test')
......
......@@ -18,7 +18,7 @@ import os
import logging
import shutil
from avocado.utils import download, archive, build
from . import download, archive, build
log = logging.getLogger('avocado.test')
......
......@@ -22,7 +22,7 @@ import glob
import math
import logging
from avocado.utils import process
from . import process
# Returns total memory in kb
......
......@@ -19,7 +19,7 @@ Avocado path related functions.
import os
import stat
from avocado.utils import aurl
from . import aurl
PY_EXTENSIONS = ['.py']
......
......@@ -34,7 +34,8 @@ except ImportError:
import subprocess
SUBPROCESS32_SUPPORT = False
from avocado import gdb
from . import gdb
from avocado import runtime
from avocado.core import exceptions
......
......@@ -21,7 +21,7 @@ import logging
import time
from avocado.core import output
from avocado.utils import process
from . import process
LOG = logging.getLogger('avocado.test')
......
......@@ -20,7 +20,7 @@ import os
import tempfile
import shutil
from avocado.utils import path as utils_path
from . import path as utils_path
class Script(object):
......
......@@ -49,10 +49,10 @@ except ImportError:
else:
HAS_YUM_MODULE = True
from avocado.utils import process
from avocado.utils import data_factory
from avocado.utils import distro
from avocado.utils import path as utils_path
from . import process
from . import data_factory
from . import distro
from . import path as utils_path
log = logging.getLogger('avocado.test')
......
......@@ -19,7 +19,7 @@ Module to provide classes for Virtual Machines.
import logging
from xml.dom import minidom
from avocado.utils import remote
from . import remote
LOG = logging.getLogger('avocado.test')
......
......@@ -159,5 +159,5 @@ doctest:
modules.png:
cd .. && sfood --internal avocado | sfood-graph --remove-extensions | \
grep -v 'size = "8,10"' | sed 's/fontsize=7/fontsize=16/' | \
grep -v 'avocado.core.plugins' | grep -v 'avocado.restclient' | \
grep -v 'avocado.core.plugins' | grep -v 'avocado.core.restclient' | \
dot -Tpng -o docs/source/modules.png
# Copyright: Red Hat Inc. 2015
# Author: Cleber Rosa <cleber@redhat.com>
from avocado.restclient import connection
from avocado.restclient import response
c = connection.get_default()
print(c.get_api_list())
# Copyright: Red Hat Inc. 2015
# Author: Cleber Rosa <cleber@redhat.com>
from avocado.restclient import connection
c = connection.get_default()
if c.ping():
print("ping: Success")
else:
print("ping: Failure")
# Copyright: Red Hat Inc. 2015
# Author: Cleber Rosa <cleber@redhat.com>
from avocado.restclient import connection
c = connection.get_default()
print(c.request("version"))
......@@ -3,8 +3,8 @@
import os
from avocado import Test
from avocado import gdb
from avocado import main
from avocado.utils import gdb
from avocado.utils import process
......
......@@ -3,9 +3,9 @@
import os
import shutil
from avocado import gdb
from avocado import main
from avocado import Test
from avocado.utils import gdb
from avocado.utils import build
......
......@@ -9,5 +9,5 @@ libvirt-python>=1.2.9
pyliblzma>=0.5.3
# HTML report plugin (avocado.core.plugins.htmlresult)
pystache>=0.5.3
# REST client (avocado.restclient)
# REST client (avocado.core.restclient)
requests>=1.2.3
......@@ -13,7 +13,7 @@ basedir = os.path.abspath(basedir)
if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
from avocado import data_dir
from avocado.core import data_dir
from avocado.core import job_id
from avocado.utils import process
......
......@@ -13,7 +13,7 @@ basedir = os.path.dirname(basedir)
if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
from avocado import settings
from avocado.core import settings
def _get_bogus_settings(args):
......@@ -47,7 +47,7 @@ class DataDirTest(unittest.TestCase):
# Trick the module to think we're on a system wide install
stg.intree = False
flexmock(settings, settings=stg)
from avocado import data_dir
from avocado.core import data_dir
flexmock(data_dir, settings=stg)
self.assertFalse(data_dir.settings.intree)
reload(data_dir)
......
......@@ -9,7 +9,7 @@ if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
from avocado import gdb
from avocado.utils import gdb
class GDBRemoteTest(unittest.TestCase):
......
......@@ -2,7 +2,7 @@ import itertools
import pickle
import sys
from avocado import multiplexer
from avocado.core import multiplexer
from avocado.core import tree
if sys.version_info[:2] == (2, 6):
......
......@@ -5,7 +5,7 @@ import os
from flexmock import flexmock, flexmock_teardown
from avocado import data_dir
from avocado.core import data_dir
from avocado.core import remote
from avocado.utils import archive
from avocado.utils import remote as utils_remote
......
......@@ -8,7 +8,7 @@ basedir = os.path.dirname(basedir)
if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
from avocado.restclient import response
from avocado.core.restclient import response
class ResultResponseTest(unittest.TestCase):
......
......@@ -13,7 +13,7 @@ basedir = os.path.dirname(basedir)
if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
from avocado import settings
from avocado.core import settings
example_1 = """[foo]
str_key = frobnicate
......
......@@ -75,8 +75,6 @@ def get_data_files():
data_files += [(get_dir(['usr', 'share', 'avocado', 'wrappers'],
['wrappers']),
glob.glob('examples/wrappers/*.sh'))]
data_files += [(get_dir(['usr', 'share', 'avocado', 'api'], ['api']),
glob.glob('examples/api/*/*.py'))]
data_files.append((get_avocado_libexec_dir(), glob.glob('libexec/*')))
return data_files
......@@ -111,7 +109,6 @@ if __name__ == '__main__':
'avocado.core.plugins',
'avocado.utils',
'avocado.core.remote',
'avocado.restclient',
'avocado.core.restclient',
'avocado.core.restclient.cli',
'avocado.core.restclient.cli.args',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册