X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fconftest.py;h=a6f83f145e47e19a54f6a6b441cd45fae9488f42;hb=e97e5f898a2bfeac786b9022ed151665be435376;hp=abb6f3a79ab640bb4baa164e09bed37043c8f59a;hpb=422af280b72461958a993165388d16098fce0f07;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index abb6f3a..a6f83f1 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -56,6 +56,9 @@ import xlsxwriter from six import string_types import version +import logging + +logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.ERROR) __path__ = [os.path.dirname(os.path.abspath(__file__))] @@ -195,6 +198,13 @@ class TestResult: """ return self.item.function.__module__.split(".")[-1] + @property + def test_id(self): + """ + :return: ID of the test (test_module + test_case) + """ + return "{}::{}".format(self.test_module, self.test_case) + @property def raw_output(self): """ @@ -312,7 +322,6 @@ def pytest_runtest_makereport(item, call): if outcome.get_result().when != "call": return # only capture results of test cases themselves result = TestResult(item, outcome) - ALL_RESULTS.append(result) if ( not item.config.option.continue_on_failure and result.is_base_test @@ -321,8 +330,12 @@ def pytest_runtest_makereport(item, call): msg = "!!Base Test Failure!! Halting test suite execution...\n{}".format( result.error_message ) + result.error_message = msg + ALL_RESULTS.append(result) pytest.exit("{}\n{}\n{}".format(msg, result.files, result.test_case)) + ALL_RESULTS.append(result) + def make_timestamp(): """ @@ -522,7 +535,7 @@ def generate_csv_report(output_dir, categories, template_path, failures): rows.append( [ "\n".join(failure.files), - failure.test_module, + failure.test_id, failure.requirement_text(reqs), failure.resolution_steps(resolutions), failure.error_message, @@ -586,7 +599,7 @@ def generate_excel_report(output_dir, categories, template_path, failures): # table content for row, failure in enumerate(failures, start=start_error_table_row + 2): worksheet.write(row, 0, "\n".join(failure.files), normal) - worksheet.write(row, 1, failure.test_module, normal) + worksheet.write(row, 1, failure.test_id, normal) worksheet.write(row, 2, failure.requirement_text(reqs), normal) worksheet.write(row, 3, failure.resolution_steps(resolutions), normal) worksheet.write(row, 4, failure.error_message, normal) @@ -805,7 +818,7 @@ def generate_html_report(outpath, categories, template_path, failures): fail_data.append( { "file_links": make_href(failure.files), - "test_id": failure.test_module, + "test_id": failure.test_id, "error_message": failure.error_message, "raw_output": failure.raw_output, "requirements": docutils.core.publish_parts( @@ -1045,9 +1058,9 @@ def select_heat_requirements(reqs): def is_testable(reqs): """Filters dict requirements to only those which are testable""" for key, values in reqs.items(): - if (("MUST" in values.get("keyword", "").upper()) and ( + if ("MUST" in values.get("keyword", "").upper()) and ( "none" not in values.get("validation_mode", "").lower() - )): + ): reqs[key]["testable"] = True else: reqs[key]["testable"] = False