Skip to content

Commit 095087e

Browse files
Copilotlostmsu
andcommitted
Fix PicklingError in subprocess spawn by moving fixtures to conftest.py
Co-authored-by: lostmsu <239520+lostmsu@users.noreply.github.com>
1 parent 4eee659 commit 095087e

2 files changed

Lines changed: 25 additions & 22 deletions

File tree

tests/conftest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pathlib import Path
2+
from subprocess import check_call
3+
4+
import pytest
5+
6+
NETCORE_VERSION = "net10.0"
7+
8+
9+
@pytest.fixture(scope="session")
10+
def example_netstandard(tmp_path_factory: pytest.TempPathFactory) -> Path:
11+
return build_example(tmp_path_factory, "netstandard2.0")
12+
13+
14+
@pytest.fixture(scope="session")
15+
def example_netcore(tmp_path_factory: pytest.TempPathFactory) -> Path:
16+
return build_example(tmp_path_factory, NETCORE_VERSION)
17+
18+
19+
def build_example(tmp_path_factory: pytest.TempPathFactory, framework: str) -> Path:
20+
out = tmp_path_factory.mktemp(f"example-{framework}")
21+
proj_path = Path(__file__).parent.parent / "example" / "example.csproj"
22+
23+
_ = check_call(["dotnet", "build", str(proj_path), "-o", str(out), "-f", framework])
24+
25+
return out

tests/test_common.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
11
import shutil
22
import sys
33
from pathlib import Path
4-
from subprocess import check_call
54

65
import pytest
76

8-
NETCORE_VERSION = "net10.0"
9-
10-
11-
@pytest.fixture(scope="session")
12-
def example_netstandard(tmp_path_factory: pytest.TempPathFactory) -> Path:
13-
return build_example(tmp_path_factory, "netstandard2.0")
14-
15-
16-
@pytest.fixture(scope="session")
17-
def example_netcore(tmp_path_factory: pytest.TempPathFactory) -> Path:
18-
return build_example(tmp_path_factory, NETCORE_VERSION)
19-
20-
21-
def build_example(tmp_path_factory: pytest.TempPathFactory, framework: str) -> Path:
22-
out = tmp_path_factory.mktemp(f"example-{framework}")
23-
proj_path = Path(__file__).parent.parent / "example" / "example.csproj"
24-
25-
_ = check_call(["dotnet", "build", str(proj_path), "-o", str(out), "-f", framework])
26-
27-
return out
28-
297

308
def test_mono(example_netstandard: Path):
319
from clr_loader import get_mono

0 commit comments

Comments
 (0)