MCPcopy
hub / github.com/pytest-dev/pytest / is_collection_argument_subsumed_by

Function is_collection_argument_subsumed_by

src/_pytest/main.py:1166–1187  ·  view source on GitHub ↗

Check if `arg` is subsumed (contained) by `by`.

(
    arg: CollectionArgument, by: CollectionArgument
)

Source from the content-addressed store, hash-verified

1164
1165
1166def is_collection_argument_subsumed_by(
1167 arg: CollectionArgument, by: CollectionArgument
1168) -> bool:
1169 """Check if `arg` is subsumed (contained) by `by`."""
1170 # First check path subsumption.
1171 if by.path != arg.path:
1172 # `by` subsumes `arg` if `by` is a parent directory of `arg` and has no
1173 # parts (collects everything in that directory).
1174 if not by.parts:
1175 return arg.path.is_relative_to(by.path)
1176 return False
1177 # Paths are equal, check parts.
1178 # For example: ("TestClass",) is a prefix of ("TestClass", "test_method").
1179 if len(by.parts) > len(arg.parts) or arg.parts[: len(by.parts)] != by.parts:
1180 return False
1181 # Paths and parts are equal, check parametrization.
1182 # A `by` without parametrization (None) matches everything, e.g.
1183 # `pytest x.py::test_it` matches `x.py::test_it[0]`. Otherwise must be
1184 # exactly equal.
1185 if by.parametrization is not None and by.parametrization != arg.parametrization:
1186 return False
1187 return True
1188
1189
1190def normalize_collection_arguments(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected