diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 17224e59..f30a84ae 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from contextlib import contextmanager from unittest.mock import MagicMock, AsyncMock from pytest import fixture from twisted.internet import defer @@ -105,3 +104,14 @@ def client(): client.tor = None client.tor_mode = TorMode.DISABLED return client + + +@fixture(autouse=True) +def reset_storage(host): + """Replace storage with a fresh mock before each test. + + The host and storage fixtures use session scope, which means any assignments to + storage attributes (e.g., storage.method = AsyncMock(...)) persist across tests. This + fixture ensures each test starts with a clean slate. + """ + host.memory.storage = AsyncMock()