Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for alternate keychains in expression. #580

Merged
merged 3 commits into from Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -2,6 +2,8 @@ v23.6.0
-------

* #575: Only require ``importlib_metadata`` on older Pythons.
* #579: Add ``.with_keychain`` method on macOS for easy reference
to alternate keychains.

v23.5.1
-------
Expand Down
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
5 changes: 5 additions & 0 deletions tests/backends/test_macOS.py
Expand Up @@ -12,3 +12,8 @@
class Test_macOSKeychain(BackendBasicTests):
def init_keyring(self):
return macOS.Keyring()

def test_alternate_keychain(self):
alt = self.keyring.with_keychain('abcd')
assert alt.keychain == 'abcd'
assert self.keyring.keychain != 'abcd'