MCPcopy Index your code
hub / github.com/StackStorm/st2 / get_group

Function get_group

conftest.py:40–54  ·  view source on GitHub ↗

Get the items from the passed in group based on group count.

(
    items: Iterable[nodes.Node], group_count: int, group_id: int
)

Source from the content-addressed store, hash-verified

38
39
40def get_group(
41 items: Iterable[nodes.Node], group_count: int, group_id: int
42) -> Sequence[nodes.Node]:
43 """Get the items from the passed in group based on group count."""
44 if not (0 <= group_id < group_count):
45 raise ValueError("Invalid test-group argument")
46
47 def get_group_id(node: nodes.Node) -> int:
48 # use the file path instead of node id, so all tests in a file run together.
49 path_bytes = str(node.path).encode()
50 digest_bytes = hashlib.sha256(path_bytes).digest()
51 digest = int.from_bytes(digest_bytes, "little")
52 return digest % group_count
53
54 return [item for item in items if get_group_id(item) == group_id]
55
56
57def pytest_addoption(parser):

Callers 1

Calls 1

get_group_idFunction · 0.70

Tested by

no test coverage detected