Jonathan Ballet committed bfdab40

Use an in-memory to launch Gnome keyring tests, to not pollute the user keyring

Previously, tests were creating keys in the default keyring of the user and
weren't cleaned up. Mess ensued.

Now, the in-memory 'session' keyring is automatically cleaned up at logoff,
which is, although not perfect yet (states pre/post test are different), a bit

  • Participants
  • Parent commits 4d63f51

Comments (0)

Files changed (3)

 * Most of the tests don't require user interaction anymore.
 * Entries stored in Gnome Keyring appears now with a meaningful name if you try
   to browser your keyring (for ex. with Seahorse)
+* Tests from Gnome Keyring no longer pollute the user own keyring.

File keyring/

 class GnomeKeyring(KeyringBackend):
     """Gnome Keyring"""
+    # Name of the keyring to store the passwords in.
+    # Use None for the default keyring.
+    KEYRING_NAME = None
     def supported(self):
             import gnomekeyring
-                None, gnomekeyring.ITEM_NETWORK_PASSWORD,
+                self.KEYRING_NAME, gnomekeyring.ITEM_NETWORK_PASSWORD,
                 "Password for '%s' on '%s'" % (username, service),
                 {'user': username, 'domain': service},
                 password, True)

File keyring/tests/

     def init_keyring(self):
-        return keyring.backend.GnomeKeyring()
+        k = keyring.backend.GnomeKeyring()
+        # Store passwords in the session (in-memory) keyring for the tests. This
+        # is going to be automatically cleared when the user logoff.
+        k.KEYRING_NAME = 'session'
+        return k
     def test_supported(self):
         with ImportBlesser('gnomekeyring'):