未验证 提交 21877980 编写于 作者: C Cleber Rosa

Merge remote-tracking branch 'ldoktor/inf-recursion-selftests-proper'

Signed-off-by: NCleber Rosa <crosa@redhat.com>
import logging
import os
import pkg_resources
import sys
......@@ -52,6 +53,21 @@ def python_module_available(module_name):
return False
def setup_avocado_loggers():
"""
Setup avocado loggers to contain at least one logger
This is required for tests that directly utilize avocado.Test classes
because they require those loggers to be configured. Without this
it might (py2) result in infinite recursion while attempting to log
"No handlers could be found for logger ..." message.
"""
for name in ('', 'avocado.test', 'avocado.app'):
logger = logging.getLogger(name)
if not logger.handlers:
logger.handlers.append(logging.NullHandler())
#: The plugin module names and directories under optional_plugins
PLUGINS = {'varianter_yaml_to_mux': 'avocado-framework-plugin-varianter-yaml-to-mux',
'runner_remote': 'avocado-framework-plugin-runner-remote',
......
......@@ -16,6 +16,11 @@ from avocado.core import job
from avocado.core import test
from avocado.utils import path as utils_path
from .. import setup_avocado_loggers
setup_avocado_loggers()
class JobTest(unittest.TestCase):
......
......@@ -6,6 +6,10 @@ from six import PY3
from avocado.core import jobdata
from .. import BASEDIR
from .. import setup_avocado_loggers
setup_avocado_loggers()
class JobdataTest(unittest.TestCase):
......
......@@ -10,6 +10,11 @@ from avocado.core import job
from avocado.core.result import Result
from avocado.plugins import jsonresult
from .. import setup_avocado_loggers
setup_avocado_loggers()
class FakeJob(object):
......
......@@ -8,6 +8,12 @@ from avocado.core import test
from avocado.core import loader
from avocado.utils import script
from .. import setup_avocado_loggers
setup_avocado_loggers()
#: What is commonly known as "0664" or "u=rw,g=rw,o=r"
DEFAULT_NON_EXEC_MODE = (stat.S_IRUSR | stat.S_IWUSR |
stat.S_IRGRP | stat.S_IWGRP |
......
......@@ -6,6 +6,11 @@ import unittest
from avocado.core import test
from avocado.plugins import replay
from .. import setup_avocado_loggers
setup_avocado_loggers()
class Replay(unittest.TestCase):
......
......@@ -11,6 +11,11 @@ from avocado.core.result import Result
from avocado.core.runner import TestRunner
from avocado.core.tree import TreeNode
from .. import setup_avocado_loggers
setup_avocado_loggers()
class TestRunnerQueue(unittest.TestCase):
"""
......
......@@ -7,6 +7,11 @@ import unittest
from avocado.core import safeloader
from avocado.utils import script
from .. import setup_avocado_loggers
setup_avocado_loggers()
KEEP_METHODS_ORDER = '''
from avocado import Test
......
......@@ -10,6 +10,12 @@ except ImportError:
from avocado.core import test, exceptions
from avocado.utils import astring, script
from .. import setup_avocado_loggers
setup_avocado_loggers()
PASS_SCRIPT_CONTENTS = """#!/bin/sh
true
"""
......
......@@ -6,6 +6,11 @@ import unittest
from avocado.utils import asset
from avocado.utils.filelock import FileLock
from .. import setup_avocado_loggers
setup_avocado_loggers()
class TestAsset(unittest.TestCase):
......
......@@ -15,6 +15,11 @@ from avocado.utils import iso9660
from avocado.utils import network
from avocado.utils import data_factory
from .. import setup_avocado_loggers
setup_avocado_loggers()
def has_iso_create_write():
return iso9660.iso9660(os.devnull, ["create", "write"]) is not None
......
......@@ -4,6 +4,11 @@ import unittest
from avocado.utils import genio
from .. import setup_avocado_loggers
setup_avocado_loggers()
class TestGenio(unittest.TestCase):
def test_check_pattern_in_directory(self):
......
......@@ -14,6 +14,11 @@ except ImportError:
from avocado.utils import iso9660, process
from .. import setup_avocado_loggers
setup_avocado_loggers()
class Capabilities(unittest.TestCase):
......
......@@ -2,6 +2,11 @@ import unittest
from avocado.utils.kernel import KernelBuild
from .. import setup_avocado_loggers
setup_avocado_loggers()
class TestKernelBuild(unittest.TestCase):
def setUp(self):
......
......@@ -19,6 +19,11 @@ from avocado.utils import path
from six import string_types, PY2
from .. import setup_avocado_loggers
setup_avocado_loggers()
def probe_binary(binary):
try:
......
......@@ -25,6 +25,11 @@ except ImportError:
from avocado.utils import service
from .. import setup_avocado_loggers
setup_avocado_loggers()
class TestMultipleInstances(unittest.TestCase):
......
......@@ -4,6 +4,11 @@ import unittest
from avocado.utils import distro
from avocado.utils import software_manager
from .. import setup_avocado_loggers
setup_avocado_loggers()
def apt_supported_distro():
"""
......
......@@ -8,6 +8,11 @@ from six.moves.urllib.error import HTTPError
from avocado.utils import vmimage
from .. import setup_avocado_loggers
setup_avocado_loggers()
class VMImage(unittest.TestCase):
......
......@@ -21,6 +21,11 @@ from avocado.core import job
from avocado.core.result import Result
from avocado.plugins import xunit
from .. import setup_avocado_loggers
setup_avocado_loggers()
class ParseXMLError(Exception):
pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册