Skip to content

Commit

Permalink
Add support for getting another Keyring with an alternate keychain. F…
Browse files Browse the repository at this point in the history
…ixes #579.
  • Loading branch information
jaraco committed Jun 5, 2022
1 parent a49e697 commit 4a1be85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions keyring/backends/macOS/__init__.py
Expand Up @@ -66,3 +66,8 @@ def delete_password(self, service, username):
raise PasswordDeleteError(
"Can't delete password in keychain: " "{}".format(e)
)

def with_keychain(self, keychain):
alt = Keyring()
alt.keychain = keychain
return alt
3 changes: 1 addition & 2 deletions tests/backends/test_macOS.py
Expand Up @@ -13,8 +13,7 @@ class Test_macOSKeychain(BackendBasicTests):
def init_keyring(self):
return macOS.Keyring()

@pytest.mark.xfail
def test_alternate_keychain(self):
alt = self.keyring.with_keychain('abcd')
assert alt.keychain == 'abcd'
assert self.keyring.keychain is None
assert self.keyring.keychain != 'abcd'

0 comments on commit 4a1be85

Please sign in to comment.