Skip to content

Commit

Permalink
refactor mock_config_path fixture to share code between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-scribner committed Jun 24, 2024
1 parent 522a056 commit 309f053
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions tests/scenario/test_machine_charm/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
from unittest.mock import patch

import pytest


@pytest.fixture
def placeholder_cfg_path(tmp_path):
return tmp_path / "foo.yaml"


@pytest.fixture()
def mock_config_path(placeholder_cfg_path):
with patch("grafana_agent.CONFIG_PATH", placeholder_cfg_path):
yield
5 changes: 2 additions & 3 deletions tests/scenario/test_machine_charm/test_alert_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@


@pytest.fixture(autouse=True)
def mock_config_path(placeholder_cfg_path):
with patch("grafana_agent.CONFIG_PATH", placeholder_cfg_path):
yield
def use_mock_config_path(mock_config_path):
yield


@pytest.fixture(autouse=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@


@pytest.fixture(autouse=True)
def mock_config_path(placeholder_cfg_path):
with patch("grafana_agent.CONFIG_PATH", placeholder_cfg_path):
yield
def use_mock_config_path(mock_config_path):
yield


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 309f053

Please sign in to comment.