Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit 0022681

Browse files
author
Kalinovsky, Konstantin
committed
Added fixture 'sequence' to mark tests, for non parallel run. Fixes #80
1 parent b03473d commit 0022681

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ pytest --tests-per-worker auto
5353
pytest --workers 2 --tests-per-worker auto
5454
```
5555

56-
## Markers
56+
## Non parallel runs
5757

58-
Use `@pytest.mark.sequence`, to mark tests, that shouldn't run in parallel mode.
58+
Use `@pytest.mark.sequence` to mark tests, that shouldn't run in parallel mode.
59+
Use fixture `sequence` to mark fixtures or tests, that shouldn't run in parallel mode.
5960

6061
## Notice
6162

pytest_parallel/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ def run(self):
103103
pass
104104

105105

106+
@pytest.fixture
107+
def sequence():
108+
"""
109+
Fixture moves test to sequence execution.
110+
Fixture can be used with another fixture.
111+
"""
112+
pass
113+
114+
106115
@pytest.mark.trylast
107116
def pytest_configure(config):
108117
workers = parse_config(config, 'workers')
@@ -297,7 +306,7 @@ def pytest_runtestloop(self, session):
297306
self.responses_queue = queue_cls()
298307

299308
for i, item in enumerate(session.items):
300-
if "sequence" in [mark.name for mark in item.own_markers]:
309+
if "sequence" in [mark.name for mark in item.own_markers] or "sequence" in item._fixtureinfo.names_closure:
301310
sequence_queue.put(i)
302311
else:
303312
parallel_queue.put(i)

0 commit comments

Comments
 (0)