Skip to content

Commit

Permalink
Only run macOS backend tests when the backend is viable. Fixes #529. F…
Browse files Browse the repository at this point in the history
…ixes #547.
  • Loading branch information
jaraco committed Nov 25, 2021
1 parent eab42e4 commit f2053c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions keyring/backends/macOS/__init__.py
Expand Up @@ -28,6 +28,8 @@ def priority(cls):
"""
if platform.system() != 'Darwin':
raise RuntimeError("macOS required")
if 'api' not in globals():
raise RuntimeError("Security API unavailable")
return 5

def set_password(self, service, username, password):
Expand Down
12 changes: 5 additions & 7 deletions tests/backends/test_macOS.py
@@ -1,16 +1,14 @@
import sys

import pytest

import keyring
from keyring.testing.backend import BackendBasicTests
from keyring.backends import macOS


def is_osx_keychain_supported():
return sys.platform in ('mac', 'darwin')


@pytest.mark.skipif(not is_osx_keychain_supported(), reason="Needs macOS")
@pytest.mark.skipif(
not keyring.backends.Windows.WinVaultKeyring.viable,
reason="macOS backend not viable",
)
class TestOSXKeychain(BackendBasicTests):
def init_keyring(self):
return macOS.Keyring()

0 comments on commit f2053c3

Please sign in to comment.