# Path: keyring/testing/util.py
# def random_string(k, source=ALPHABET):
#     """Generate a random string with length <i>k</i>"""
#     result = ''
#     for i in range(0, k):
#         result += random.choice(source)
#     return result
# 
# Path: keyring/errors.py
# class KeyringError(Exception):
# class PasswordSetError(KeyringError):
# class PasswordDeleteError(KeyringError):
# class InitError(KeyringError):
# class KeyringLocked(KeyringError):
# class NoKeyringError(KeyringError, RuntimeError):
# class ExceptionRaisedContext:
# class ExceptionInfo:
#     def __init__(self, ExpectedException=Exception):
#     def __enter__(self):
#     def __exit__(self, *exc_info):
#     def __init__(self, *info):
#     def __bool__(self):


import os
import string
import pytest
from .util import random_string
from keyring import errors
    def _init_properties(self, request):
        self.keyring = self.init_keyring()
        self.credentials_created = set()
        request.addfinalizer(self.cleanup)

    def cleanup(self):
        for item in self.credentials_created:
            self.keyring.delete_password(*item)

    def set_password(self, service, username, password):
        # set the password and save the result so the test runner can clean
        #  up after if necessary.
        self.keyring.set_password(service, username, password)
        self.credentials_created.add((service, username))

    def check_set_get(self, service, username, password):
        keyring = self.keyring

        # for the non-existent password
        assert keyring.get_password(service, username) is None

        # common usage
        self.set_password(service, username, password)
        assert keyring.get_password(service, username) == password

        # for the empty password
        self.set_password(service, username, "")
        assert keyring.get_password(service, username) == ""

    def test_password_set_get(self):

# Path: keyring/testing/util.py
# def random_string(k, source=ALPHABET):
#     """Generate a random string with length <i>k</i>"""
#     result = ''
#     for i in range(0, k):
#         result += random.choice(source)
#     return result
# 
# Path: keyring/errors.py
# class KeyringError(Exception):
# class PasswordSetError(KeyringError):
# class PasswordDeleteError(KeyringError):
# class InitError(KeyringError):
# class KeyringLocked(KeyringError):
# class NoKeyringError(KeyringError, RuntimeError):
# class ExceptionRaisedContext:
# class ExceptionInfo:
#     def __init__(self, ExpectedException=Exception):
#     def __enter__(self):
#     def __exit__(self, *exc_info):
#     def __init__(self, *info):
#     def __bool__(self):


# Path: keyring/testing/backend.py
import os
import string
import pytest
from .util import random_string
from keyring import errors

    def _init_properties(self, request):
        self.keyring = self.init_keyring()
        self.credentials_created = set()
        request.addfinalizer(self.cleanup)

    def cleanup(self):
        for item in self.credentials_created:
            self.keyring.delete_password(*item)

    def set_password(self, service, username, password):
        # set the password and save the result so the test runner can clean
        #  up after if necessary.
        self.keyring.set_password(service, username, password)
        self.credentials_created.add((service, username))

    def check_set_get(self, service, username, password):
        keyring = self.keyring

        # for the non-existent password
        assert keyring.get_password(service, username) is None

        # common usage
        self.set_password(service, username, password)
        assert keyring.get_password(service, username) == password

        # for the empty password
        self.set_password(service, username, "")
        assert keyring.get_password(service, username) == ""

    def test_password_set_get(self):

        password = random_string(20)