X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fconftest.py;h=98680678aff8c1bfa25872f8db82f5c673b632c9;hb=refs%2Fchanges%2F84%2F94384%2F1;hp=7fe94439ee8899300d822bf5fd4e2e742a077895;hpb=0907dd0dcd870afc12d4cb245d970fefff803898;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index 7fe9443..9868067 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -43,6 +43,11 @@ import json import os import re import time + +from preload.model import create_preloads +from config import get_generator_plugin_names +from tests.helpers import get_output_dir + try: from html import escape except ImportError: @@ -95,18 +100,6 @@ COLLECTION_FAILURES = [] ALL_RESULTS = [] -def get_output_dir(config): - """ - Retrieve the output directory for the reports and create it if necessary - :param config: pytest configuration - :return: output directory as string - """ - output_dir = config.option.output_dir or DEFAULT_OUTPUT_DIR - if not os.path.exists(output_dir): - os.makedirs(output_dir, exist_ok=True) - return output_dir - - def extract_error_msg(rep): """ If a custom error message was provided, then extract it otherwise @@ -352,6 +345,12 @@ def pytest_sessionfinish(session, exitstatus): ) +def pytest_terminal_summary(terminalreporter, exitstatus): + # Ensures all preload information and warnings appear after + # test results + create_preloads(terminalreporter.config, exitstatus) + + # noinspection PyUnusedLocal def pytest_collection_modifyitems(session, config, items): """ @@ -749,8 +748,9 @@ def generate_html_report(outpath, categories, template_path, failures): { "file_links": make_href(failure.files, template_path), "test_id": failure.test_id, - "error_message": escape(failure.error_message).replace("\n", - "

"), + "error_message": escape(failure.error_message).replace( + "\n", "

" + ), "raw_output": escape(failure.raw_output), "requirements": docutils.core.publish_parts( writer_name="html", source=failure.requirement_text(reqs) @@ -829,6 +829,23 @@ def pytest_addoption(parser): help="optional category of test to execute", ) + parser.addoption( + "--env-directory", + dest="env_dir", + action="store", + help="optional directory of .env files for preload generation" + ) + + parser.addoption( + "--preload-format", + dest="preload_formats", + action="append", + help=( + "Preload format to create (multiple allowed). If not provided " + "then all available formats will be created: {}" + ).format(", ".join(get_generator_plugin_names())) + ) + def pytest_configure(config): """