Skip to content

Commit 62a79c2

Browse files
fix: Test approach
1 parent 49a6e5b commit 62a79c2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/launcher/conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,36 @@
2323

2424
from functools import partial
2525
import importlib.metadata
26+
import pathlib
27+
import subprocess
28+
import sys
2629
from unittest.mock import Mock
30+
import warnings
2731

2832
import pytest
2933

3034
from ansys.tools.common.launcher import _plugins, config
3135
from ansys.tools.common.launcher.interface import LAUNCHER_CONFIG_T, LauncherProtocol
3236

3337

38+
def pytest_configure(config):
39+
"""Prepare the environment for testing plugins."""
40+
try:
41+
# Check if the package is installed (based on its name in pyproject.toml)
42+
importlib.metadata.version("pkg_with_entrypoint")
43+
except importlib.metadata.PackageNotFoundError:
44+
warnings.warn(
45+
"WARNING: 'pkg_with_entrypoint' is not installed in the environment.\n"
46+
"Please run: pip install -e tests/launcher/pkg_with_entrypoint",
47+
stacklevel=1,
48+
)
49+
pkg_path = pathlib.Path(__file__).parent / "launcher" / "pkg_with_entrypoint"
50+
subprocess.run(
51+
[sys.executable, "-m", "pip", "install", "-e", str(pkg_path.resolve())],
52+
check=True,
53+
)
54+
55+
3456
@pytest.fixture(autouse=True)
3557
def reset_config():
3658
"""Reset the configuration at the start of each test."""

0 commit comments

Comments
 (0)