X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fconftest.py;h=9a839b5add6858634a657f476ec2ac3888617216;hb=0c4e64d87728b89aa9cd4d41d738f5bfe64ceee3;hp=ecaf6625f227f286623ec9bfc6236ab320ad0819;hpb=1bc097aa957e560147b4d9af49d25e69a6692702;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index ecaf662..9a839b5 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -348,7 +348,11 @@ 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) + try: + create_preloads(terminalreporter.config, exitstatus) + except Exception: + print("Error creating preloads, skipping preload generation") + traceback.print_exc() # noinspection PyUnusedLocal @@ -360,31 +364,27 @@ def pytest_collection_modifyitems(session, config, items): config.traceability_items = list(items) # save all items for traceability if not config.option.self_test: for item in items: - # checking if test belongs to a category - if hasattr(item.function, "categories"): - if config.option.test_categories: - test_categories = getattr(item.function, "categories") - passed_categories = config.option.test_categories - if not all( - category in passed_categories for category in test_categories - ): - item.add_marker( - pytest.mark.skip( - reason=( - "Test categories do not match " - "all the passed categories" - ) - ) + passed_categories = set(config.option.test_categories or []) + all_of_categories = getattr(item.function, "all_categories", set()) + any_of_categories = getattr(item.function, "any_categories", set()) + if all_of_categories and not all_of_categories.issubset(passed_categories): + item.add_marker( + pytest.mark.skip( + reason=( + "Test categories do not match " "all the passed categories" ) - else: - item.add_marker( - pytest.mark.skip( - reason=( - "Test belongs to a category but " - "no categories were passed" - ) + ) + ) + if any_of_categories and not passed_categories.intersection( + any_of_categories + ): + item.add_marker( + pytest.mark.skip( + reason=( + "Test categories do not match " "any the passed categories" ) ) + ) items.sort( key=lambda x: (0, x.name)