diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py new file mode 100644 index 0000000000..dd66e3a910 --- /dev/null +++ b/tests/unit/conftest.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# Copyright 2022 Canonical Ltd. +# See LICENSE file for licensing details. +import pytest +from unittest.mock import PropertyMock + +# This causes every test defined in this file to run 2 times, each with +# charm.JujuVersion.has_secrets set as True or as False +@pytest.fixture(params=[True, False], autouse=True) +def _has_secrets(request, monkeypatch): + monkeypatch.setattr("charm.JujuVersion.has_secrets", PropertyMock(return_value=request.param)) + return request.param diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 07d11ae441..a4b5bb649b 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -48,14 +48,6 @@ def harness(): harness.cleanup() -# This causes every test defined in this file to run 2 times, each with -# charm.JujuVersion.has_secrets set as True or as False -@pytest.fixture(params=[True, False], autouse=True) -def _has_secrets(request, monkeypatch): - monkeypatch.setattr("charm.JujuVersion.has_secrets", PropertyMock(return_value=request.param)) - return request.param - - @patch_network_get(private_address="1.1.1.1") def test_on_install(harness): with patch("charm.subprocess.check_call") as _check_call, patch(