def test_shared_instance(self):
        """
        Using KeyringWrapper's get_shared_instance() method should return the same
        instance each time it's called
        """
        # When: multiple calls to the shared accessor are made
        kw1 = KeyringWrapper.get_shared_instance()
        kw2 = KeyringWrapper.get_shared_instance()

        # Expect: the shared instance should exist
        assert kw1 is not None
        # Expect: multiple references should point to the same instance
        assert id(kw1) == id(kw2)

        # When: destroying the shared instance
        KeyringWrapper.cleanup_shared_instance()

        # Expect: the shared instance should be cleared
        assert KeyringWrapper.get_shared_instance(
            create_if_necessary=False) is None
Exemplo n.º 2
0
 def empty_keyring(self):
     with TempKeyring(user="******",
                      service="chia-user-chia-1.8") as keychain:
         yield keychain
         KeyringWrapper.cleanup_shared_instance()
 def setup_keyring_wrapper(self):
     yield
     KeyringWrapper.cleanup_shared_instance()
     assert KeyringWrapper.get_shared_instance(
         create_if_necessary=False) is None