main
py 46 lines 1.43 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Tests for spawn_new_process_for_each_test decorator."""
4
5 from pathlib import Path
6
7 import pytest
8
9 from tests.utils import spawn_new_process_for_each_test
10
11 pytest_plugins = ["pytester"]
12
13
14 @spawn_new_process_for_each_test
15 def test_spawn_decorator_passing():
16 """Passing function should complete normally."""
17 assert 1 + 1 == 2
18
19
20 @pytest.mark.xfail(raises=RuntimeError, strict=True)
21 @spawn_new_process_for_each_test
22 def test_spawn_decorator_failure_is_caught():
23 """Failing function should raise RuntimeError, never silently pass."""
24 raise ValueError("intentional failure")
25
26
27 @spawn_new_process_for_each_test
28 def test_spawn_decorator_skip():
29 """pytest.skip inside subprocess should propagate correctly."""
30 pytest.skip("intentional skip")
31
32
33 def test_spawn_decorator_reports_skip(pytester):
34 """A child skip must remain a skip in the parent pytest report."""
35 result = pytester.runpytest_subprocess(
36 f"{Path(__file__).resolve()}::test_spawn_decorator_skip", "-rs"
37 )
38 result.assert_outcomes(skipped=1)
39 result.stdout.fnmatch_lines(["SKIPPED *intentional skip"])
40
41
42 @spawn_new_process_for_each_test
43 @pytest.mark.parametrize("x,y,expected", [(1, 2, 3), (0, 0, 0)])
44 def test_spawn_decorator_parametrized(x, y, expected):
45 """Args and kwargs must be forwarded correctly to subprocess."""
46 assert x + y == expected