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

[FIX] Use minimal keyring implementation for tests #3359

Merged
merged 2 commits into from
Nov 6, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion Orange/widgets/tests/test_credentials.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
import unittest
from unittest.mock import patch

import keyring
import keyring.errors
import keyring.backend

from Orange.widgets.credentials import CredentialManager


# minimal in-memory keyring implementation so the test is not dependent on
# the system config/services.
class Keyring(keyring.backend.KeyringBackend):
priority = 0

def __init__(self):
self.__store = {}

def set_password(self, service, username, password=None):
self.__store[(service, username)] = password

def get_password(self, service, username):
return self.__store.get((service, username), None)

def delete_password(self, service, username):
try:
del self.__store[service, username]
except KeyError:
raise keyring.errors.PasswordDeleteError()


class TestCredentialManager(unittest.TestCase):
def setUp(self):
self._ring = keyring.get_keyring()
keyring.set_keyring(Keyring())
self.cm = CredentialManager('Orange')
self.cm.key = "Foo"

def tearDown(self):
keyring.set_keyring(self._ring)

def test_credential_manager(self):
cm = CredentialManager('Orange')
Expand Down
2 changes: 1 addition & 1 deletion requirements-core.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip>=9.0
numpy>=1.9.0
numpy>=1.13.0
scipy>=0.16.1
scikit-learn>=0.18.1
bottleneck>=1.0.0
Expand Down