API documentation
algorithms
AlgorithmBase
Bases: ABC
Abstract base class for the algorithm implementations.
Source code in src/pytest_split/algorithms.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
DurationBasedChunksAlgorithm
Bases: AlgorithmBase
Split tests into groups by runtime. Ensures tests are split into non-overlapping groups. The original list of test items is split into groups by finding boundary indices i_0, i_1, i_2 and creating group_1 = items[0:i_0], group_2 = items[i_0, i_1], group_3 = items[i_1, i_2], ...
:param splits: How many groups we're splitting in. :param items: Test items passed down by Pytest. :param durations: Our cached test runtimes. Assumes contains timings only of relevant tests :return: List of TestGroup
Source code in src/pytest_split/algorithms.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
LeastDurationAlgorithm
Bases: AlgorithmBase
Split tests into groups by runtime. It walks the test items, starting with the test with largest duration. It assigns the test with the largest runtime to the group with the smallest duration sum.
The algorithm sorts the items by their duration. Since the sorting algorithm is stable, ties will be broken by maintaining the original order of items. It is therefore important that the order of items be identical on all nodes that use this plugin. Due to issue #25 this might not always be the case.
:param splits: How many groups we're splitting in. :param items: Test items passed down by Pytest. :param durations: Our cached test runtimes. Assumes contains timings only of relevant tests :return: List of groups
Source code in src/pytest_split/algorithms.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
ipynb_compatibility
ensure_ipynb_compatibility(group: TestGroup, items: list) -> None
Ensures that group doesn't contain partial IPy notebook cells.
pytest-split
might, in principle, break up the cells of an
IPython notebook into different test groups, in which case the tests
most likely fail (for starters, libraries are imported in Cell 0, so
all subsequent calls to the imported libraries in the following cells
will raise NameError
).
Source code in src/pytest_split/ipynb_compatibility.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
plugin
Base
Source code in src/pytest_split/plugin.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
__init__(config: Config) -> None
Load durations and set up a terminal writer.
This logic is shared for both the split- and cache plugin.
Source code in src/pytest_split/plugin.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
PytestSplitCachePlugin
Bases: Base
The cache plugin writes durations to our durations file.
Source code in src/pytest_split/plugin.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
pytest_sessionfinish() -> None
Method is called by Pytest after the test-suite has run. https://github.com/pytest-dev/pytest/blob/main/src/_pytest/main.py#L308
Source code in src/pytest_split/plugin.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
PytestSplitPlugin
Bases: Base
Source code in src/pytest_split/plugin.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
pytest_collection_modifyitems(config: Config, items: List[nodes.Item]) -> None
Collect and select the tests we want to run, and deselect the rest.
Source code in src/pytest_split/plugin.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
pytest_addoption(parser: Parser) -> None
Declare pytest-split's options.
Source code in src/pytest_split/plugin.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]
Validate options.
Source code in src/pytest_split/plugin.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
pytest_configure(config: Config) -> None
Enable the plugins we need.
Source code in src/pytest_split/plugin.py
105 106 107 108 109 110 111 112 113 114 115 |
|