MCPcopy
hub / github.com/saltstack/salt / pytest_collection_modifyitems

Function pytest_collection_modifyitems

tests/conftest.py:598–639  ·  view source on GitHub ↗

called after collection has been performed, may filter or re-order the items in-place. :param _pytest.main.Session session: the pytest session object :param _pytest.config.Config config: pytest config object :param List[_pytest.nodes.Item] items: list of item objects

(config, items)

Source from the content-addressed store, hash-verified

596
597@pytest.hookimpl(hookwrapper=True, trylast=True)
598def pytest_collection_modifyitems(config, items):
599 """
600 called after collection has been performed, may filter or re-order
601 the items in-place.
602
603 :param _pytest.main.Session session: the pytest session object
604 :param _pytest.config.Config config: pytest config object
605 :param List[_pytest.nodes.Item] items: list of item objects
606 """
607 # Let PyTest or other plugins handle the initial collection
608 yield
609 groups_collection_modifyitems(config, items)
610 from_filenames_collection_modifyitems(config, items)
611
612 timeout_marker_tests_paths = (
613 str(PYTESTS_DIR / "pkg"),
614 str(PYTESTS_DIR / "scenarios"),
615 )
616 for item in items:
617 marker = item.get_closest_marker("timeout_unless_on_windows")
618 if marker is not None:
619 if not salt.utils.platform.is_windows():
620 # Apply the marker since we're not on windows
621 marker_kwargs = marker.kwargs.copy()
622 if "func_only" not in marker_kwargs:
623 # Default to counting only the test execution for the timeouts, ie,
624 # withough including the fixtures setup time towards the timeout.
625 marker_kwargs["func_only"] = True
626 item.add_marker(pytest.mark.timeout(*marker.args, **marker_kwargs))
627 else:
628 if (
629 not salt.utils.platform.is_windows()
630 and not str(pathlib.Path(item.fspath).resolve()).startswith(
631 timeout_marker_tests_paths
632 )
633 and not item.get_closest_marker("timeout")
634 ):
635 # Let's apply the timeout marker on the test, if the marker
636 # is not already applied
637 # Default to counting only the test execution for the timeouts, ie,
638 # withough including the fixtures setup time towards the timeout.
639 item.add_marker(pytest.mark.timeout(90, func_only=True))
640
641
642def pytest_markeval_namespace(config):

Callers

nothing calls this directly

Calls 3

copyMethod · 0.45

Tested by

no test coverage detected