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: help_docs/customizing_test_runs.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -277,12 +277,34 @@ The code above will leave your browser window open in case there's a failure. (p
277
277
🎛️ There are times when you'll want to combine various command-line options for added effect.
278
278
For instance, the multi-process option, ``-n8``, can be customized by adding:
279
279
``--dist=loadscope`` or ``--dist=loadfile`` to it.
280
-
Here's more info on that, as taken from [pytest-xdist](https://pypi.org/project/pytest-xdist/):
280
+
There's more info on that here: [pytest-xdist](https://pypi.org/project/pytest-xdist/2.5.0/):
281
281
282
282
*``-n8 --dist=loadscope``: Tests are grouped by module for test functions and by class for test methods. Groups are distributed to available workers as whole units. This guarantees that all tests in a group run in the same process. This can be useful if you have expensive module-level or class-level fixtures. Grouping by class takes priority over grouping by module.
283
283
284
284
*``-n8 --dist=loadfile``: Tests are grouped by their containing file. Groups are distributed to available workers as whole units. This guarantees that all tests in a file run in the same worker.
285
285
286
+
<details>
287
+
<summary> ▶️ <code>-n8 --dist=loadgroup</code> (<b>click to expand</b>)</summary>
288
+
<div>
289
+
290
+
<ul><li>Tests are grouped by the <code>xdist_group</code> mark. Groups are distributed to available workers as whole units. This guarantees that all tests with the same <code>xdist_group</code> name run in the same worker.</li></ul>
291
+
292
+
```python
293
+
@pytest.mark.xdist_group(name="group1")
294
+
deftest_1():
295
+
pass
296
+
297
+
classTest:
298
+
@pytest.mark.xdist_group("group1")
299
+
deftest_2():
300
+
pass
301
+
```
302
+
303
+
<blockquote><p>This makes <code>test_1</code> and <code>Test::test_2</code> run in the same worker. Tests without the <code>xdist_group</code> mark are distributed normally.</p></blockquote>
304
+
305
+
</div>
306
+
</details>
307
+
286
308
🎛️ You might also want to combine multiple options at once. For example:
0 commit comments