X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fconftest.py;h=f4b3857cdcfcbe2346d5db0df5f98722fb598d54;hb=940ae7b0283191d590de40b71a9136bebc80e83c;hp=b09a8aa7ac71b78bc6bcc29585f40b5009f7bd0a;hpb=ac00e6ea5fe3f53fa4d4b57e0e302f6bceca7066;p=vvp%2Fvalidation-scripts.git
diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py
index b09a8aa..f4b3857 100644
--- a/ice_validator/tests/conftest.py
+++ b/ice_validator/tests/conftest.py
@@ -43,6 +43,14 @@ import json
import os
import re
import time
+
+from preload import create_preloads
+from tests.helpers import get_output_dir
+
+try:
+ from html import escape
+except ImportError:
+ from cgi import escape
from collections import defaultdict
import traceback
@@ -91,18 +99,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
@@ -348,6 +344,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):
"""
@@ -745,8 +747,10 @@ def generate_html_report(outpath, categories, template_path, failures):
{
"file_links": make_href(failure.files, template_path),
"test_id": failure.test_id,
- "error_message": failure.error_message.replace("\n", "
"),
- "raw_output": failure.raw_output,
+ "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)
)["body"],
@@ -958,7 +962,7 @@ def hash_directory(path):
:param path: string directory containing files
:return: string MD5 hash code (hex)
"""
- md5 = hashlib.md5()
+ md5 = hashlib.md5() # nosec
for dir_path, sub_dirs, filenames in os.walk(path):
for filename in filenames:
file_path = os.path.join(dir_path, filename)