Skip to content

Commit 0ffeeed

Browse files
committed
Move Local Cache Fixture
1 parent 0c4e4f4 commit 0ffeeed

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

tests/fixtures/conan.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@
1111
from cppython.plugins.conan.schema import ConanDependency
1212

1313

14+
@pytest.fixture(autouse=True)
15+
def clean_conan_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
16+
"""Sets CONAN_HOME to a temporary directory for each test.
17+
18+
This ensures all tests run with a clean Conan cache.
19+
20+
Args:
21+
tmp_path: Pytest temporary directory fixture
22+
monkeypatch: Pytest monkeypatch fixture for environment variable manipulation
23+
"""
24+
conan_home = tmp_path / 'conan_home'
25+
conan_home.mkdir()
26+
27+
# Set CONAN_HOME to the temporary directory
28+
monkeypatch.setenv('CONAN_HOME', str(conan_home))
29+
30+
1431
@pytest.fixture(name='conan_mock_api')
1532
def fixture_conan_mock_api(mocker: MockerFixture) -> Mock:
1633
"""Creates a mock ConanAPI instance for install/update operations

tests/integration/examples/test_conan_cmake.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from cppython.core.schema import ProjectConfiguration
1515
from cppython.project import Project
1616

17-
pytest_plugins = ['tests.fixtures.example']
17+
pytest_plugins = ['tests.fixtures.example', 'tests.fixtures.conan']
1818

1919

2020
class TestConanCMake:
@@ -49,3 +49,5 @@ def test_simple(example_runner: CliRunner) -> None:
4949

5050
# Verify that the build directory contains the expected files
5151
assert (path / 'CMakeCache.txt').exists(), f'{path / "CMakeCache.txt"} not found'
52+
53+
# Publish the project to the local cache

tests/integration/plugins/conan/test_provider.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
"""Integration tests for the provider"""
22

3-
from pathlib import Path
43
from typing import Any
54

65
import pytest
76

87
from cppython.plugins.conan.plugin import ConanProvider
98
from cppython.test.pytest.contracts import ProviderIntegrationTestContract
109

11-
12-
@pytest.fixture(autouse=True)
13-
def clean_conan_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
14-
"""Sets CONAN_HOME to a temporary directory for each test.
15-
16-
This ensures all tests run with a clean Conan cache.
17-
18-
Args:
19-
tmp_path: Pytest temporary directory fixture
20-
monkeypatch: Pytest monkeypatch fixture for environment variable manipulation
21-
"""
22-
conan_home = tmp_path / 'conan_home'
23-
conan_home.mkdir()
24-
25-
# Set CONAN_HOME to the temporary directory
26-
monkeypatch.setenv('CONAN_HOME', str(conan_home))
10+
pytest_plugins = ['tests.fixtures.conan']
2711

2812

2913
class TestConanProvider(ProviderIntegrationTestContract[ConanProvider]):

0 commit comments

Comments
 (0)