def run(self): token = HfFolder.get_token() if token is None: print("Not logged in") exit() HfFolder.delete_token() self._api.logout(token) print("Successfully logged out.")
def test_token_workflow(self): """ Test the whole token save/get/delete workflow, with the desired behavior with respect to non-existent tokens. """ token = "token-{}".format(int(time.time())) HfFolder.save_token(token) self.assertEqual(HfFolder.get_token(), token) HfFolder.delete_token() HfFolder.delete_token() # ^^ not an error, we test that the # second call does not fail. self.assertEqual(HfFolder.get_token(), None)