Log changes to the _configure_legacy_backend patch

This commit is contained in:
Jeff Cruikshank 2021-10-07 20:22:51 +00:00
parent 5e043c6473
commit 26791a40b7
No known key found for this signature in database
GPG Key ID: DFBB4A99F1A6CFF5

View File

@ -13,6 +13,11 @@ from typing import Any, Optional
from unittest.mock import patch
import logging
log = logging.getLogger(__name__)
def create_empty_cryptfilekeyring() -> CryptFileKeyring:
"""
Create an empty legacy keyring
@ -148,10 +153,18 @@ class TempKeyring:
setup_mock_file_keyring(mock_configure_backend, temp_dir, populate=populate)
mock_configure_legacy_backend_patch: Any = None
log.warning(
f"[before] _patch_and_create_keychain: "
f"KeyringWrapper._configure_legacy_backend: {KeyringWrapper._configure_legacy_backend}"
)
if setup_cryptfilekeyring is False:
mock_configure_legacy_backend_patch = patch.object(KeyringWrapper, "_configure_legacy_backend")
mock_configure_legacy_backend = mock_configure_legacy_backend_patch.start()
mock_configure_legacy_backend.return_value = None
log.warning(
f"[after] _patch_and_create_keychain: "
f"KeyringWrapper._configure_legacy_backend: {KeyringWrapper._configure_legacy_backend}"
)
mock_data_root_patch = patch.object(platform_, "data_root")
mock_data_root = mock_data_root_patch.start()
@ -190,6 +203,10 @@ class TempKeyring:
return self.keychain
def cleanup(self):
log.warning(
f"[before] cleanup: "
f"KeyringWrapper._configure_legacy_backend: {KeyringWrapper._configure_legacy_backend}"
)
assert not self.cleaned_up
if self.delete_on_cleanup:
@ -206,3 +223,7 @@ class TempKeyring:
self.keychain._mock_data_root_patch.stop()
self.cleaned_up = True
log.warning(
f"[after] cleanup: "
f"KeyringWrapper._configure_legacy_backend: {KeyringWrapper._configure_legacy_backend}"
)