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

Commit 28441a1

Browse files
author
Kalinovsky, Konstantin
committed
Test for @pytest.mark.sequence
1 parent 0022681 commit 28441a1

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

tests/test_general.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_1():
237237
raise Exception('Failed to load test file')
238238
""")
239239
result = testdir.runpytest(*cli_args)
240-
result.assert_outcomes(error=1)
240+
result.assert_outcomes(errors=1)
241241
# Expect error code 2 (Interrupted), which is returned on collection error.
242242
assert result.ret == 2
243243

@@ -258,3 +258,37 @@ def test_collection_collectonly(testdir, cli_args):
258258
])
259259
result.assert_outcomes()
260260
assert result.ret == 0
261+
262+
263+
@pytest.mark.parametrize('cli_args', [
264+
['--workers=4'],
265+
['--tests-per-worker=4']
266+
])
267+
def test_sequenced_call(testdir, cli_args):
268+
"""
269+
Tests, that sequenced tests will be called in sequence.
270+
"""
271+
testdir.makepyfile("""
272+
import pytest
273+
import time
274+
275+
obj = {"a": None}
276+
277+
@pytest.mark.sequence
278+
def test_1():
279+
time.sleep(0.1)
280+
assert obj["a"] == None
281+
obj["a"] = "first"
282+
283+
@pytest.mark.sequence
284+
def test_2():
285+
assert obj["a"] == "first"
286+
obj["a"] = "second"
287+
288+
@pytest.mark.sequence
289+
def test_3():
290+
assert obj["a"] == "second"
291+
""")
292+
result = testdir.runpytest(*cli_args)
293+
result.assert_outcomes(passed=3)
294+
assert result.ret == 0

0 commit comments

Comments
 (0)