You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,20 +27,20 @@ This is of course a fundamental problem in the suite itself but sometimes it's n
27
27
Additionally, `pytest-split` may be a better fit in some use cases considering distributed execution.
28
28
29
29
## Installation
30
-
```
30
+
```sh
31
31
pip install pytest-split
32
32
```
33
33
34
34
## Usage
35
35
First we have to store test durations from a complete test suite run.
36
36
This produces .test_durations file which should be stored in the repo in order to have it available during future test runs.
37
37
The file path is configurable via `--durations-path` CLI option.
38
-
```
38
+
```sh
39
39
pytest --store-durations
40
40
```
41
41
42
42
Then we can have as many splits as we want:
43
-
```
43
+
```sh
44
44
pytest --splits 3 --group 1
45
45
pytest --splits 3 --group 2
46
46
pytest --splits 3 --group 3
@@ -59,7 +59,10 @@ Lists the slowest tests based on the information stored in the test durations fi
59
59
information.
60
60
61
61
## Interactions with other pytest plugins
62
-
*[`pytest-random-order`](https://github.com/jbasko/pytest-random-order): ⚠️ The **default settings** of that plugin (setting only `--random-order` to activate it) are **incompatible** with `pytest-split`. Test selection in the groups happens after randomization, potentially causing some tests to be selected in several groups and others not at all. Instead, a global random seed needs to be computed before running the tests (for example using `$RANDOM` from the shell) and that single seed then needs to be used for all groups by setting the `--random-order-seed` option.
62
+
*[`pytest-random-order`](https://github.com/jbasko/pytest-random-order) and [`pytest-randomly`](https://github.com/pytest-dev/pytest-randomly):
63
+
⚠️ `pytest-split` running with the `duration_based_chunks` algorithm is **incompatible** with test-order-randomization plugins.
64
+
Test selection in the groups happens after randomization, potentially causing some tests to be selected in several groups and others not at all.
65
+
Instead, a global random seed needs to be computed before running the tests (for example using `$RANDOM` from the shell) and that single seed then needs to be used for all groups by setting the `--random-order-seed` option.
63
66
64
67
*[`nbval`](https://github.com/computationalmodelling/nbval): `pytest-split` could, in principle, break up a single IPython Notebook into different test groups. This most likely causes broken up pieces to fail (for the very least, package `import`s are usually done at Cell 1, and so, any broken up piece that doesn't contain Cell 1 will certainly fail). To avoid this, after splitting step is done, test groups are reorganized based on a simple algorithm illustrated in the following cartoon:
65
68
@@ -71,14 +74,15 @@ where the letters (A to E) refer to individual IPython Notebooks, and the number
71
74
The plugin supports multiple algorithms to split tests into groups.
72
75
Each algorithm makes different tradeoffs, but generally `least_duration` should give more balanced groups.
73
76
74
-
| Algorithm | Maintains Absolute Order | Maintains Relative Order | Split Quality |
* Absolute Order: whether each group contains all tests between first and last element in the same order as the original list of tests
81
84
* Relative Order: whether each test in each group has the same relative order to its neighbours in the group as in the original list of tests
85
+
* Works with random ordering: whether the algorithm works with test-shuffling tools such as [`pytest-randomly`](https://github.com/pytest-dev/pytest-randomly)
82
86
83
87
The `duration_based_chunks` algorithm aims to find optimal boundaries for the list of tests and every test group contains all tests between the start and end boundary.
84
88
The `least_duration` algorithm walks the list of tests and assigns each test to the group with the smallest current duration.
0 commit comments