Testing OpenStack upgrades
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.3 KiB

# Copyright (c) 2020 Red Hat
# All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
from datetime import datetime
from oslo_log import log
from py.xml import html # pylint: disable=no-name-in-module,import-error
import pytest
LOG = log.getLogger(__name__)
def pytest_configure(config):
def configure_caplog(config):
import tobiko
tobiko_config = tobiko.tobiko_config()
if tobiko_config.logging.capture_log is True:
if tobiko_config.debug:
default = 'DEBUG'
default = 'INFO'
default = 'FATAL'
for key in ['log_level',
set_default_inicfg(config, key, default)
default = tobiko_config.logging_default_format_string
if default:
# instance and color are not supported by pytest
default = default.replace('%(instance)s', '')
default = default.replace('%(color)s', '')
if default:
for key in ['log_format',
set_default_inicfg(config, key, default)
default = tobiko_config.log_date_format
if default:
for key in ['log_date_format',
set_default_inicfg(config, key, default)
def set_default_inicfg(config, key, default):
value = config.inicfg.setdefault(key, default)
if value != default:
LOG.debug(f"Set default inicfg: {key} = {value}")
LOG.debug(f"Keep existing inicfg: {key} = {value}")
def configure_timeout(config):
import tobiko
tobiko_config = tobiko.tobiko_config()
default = tobiko_config.testcase.timeout
if default is not None and default > 0.:
set_default_inicfg(config, 'timeout', default)
def pytest_html_results_table_header(cells):
cells.insert(2, html.th("Description"))
cells.insert(1, html.th("Time", class_="sortable time", col="time"))
def pytest_html_results_table_row(report, cells):
cells.insert(2, html.td(report.description))
cells.insert(1, html.td(datetime.utcnow(), class_="col-time"))
def pytest_runtest_makereport(item, call): # pylint: disable=unused-argument
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
def pytest_runtest_call(item):
# pylint: disable=protected-access
import tobiko